mnetcdf (python) pnetcdf(fortran)


Magics is capable of reading NetCDF data files. A family of NetCDF parameters enable the user to define how to interpret the NetCDF data.

New in 3.0.0

From this version, Magics will offer a easier setting of the NetCDF object. The principle is to make it aware of some commonly used conventions of NetCDF representations. For example It will try to identify the latitudes and longitudes axis to set-up the geo-reference. This is work in progress, and we plan to introduce more of these conventions in the next releases.

Example of metadata (ncdump):

ncdump
//Variables		
	   float longitude(longitude) ;
                longitude:units = "degrees_east" ; <-- Magics will recognise this variable as describing a longitude axis
                longitude:long_name = "longitude" ;
        float latitude(latitude) ;
                latitude:units = "degrees_north" ; <-- Magics will recognise this variable as describing a longitude axis
                latitude:long_name = "latitude" ;
        int time(time) ;
                time:units = "hours since 1900-01-01 00:00:0.0" ;  <-- Magics will interpret the date
                time:long_name = "time" ;
                time:calendar = "gregorian" ;
        short t2a(time, latitude, longitude) ; <-- Magics will recognise a geographical data 
                t2a:scale_factor = 0.000146876453558398 ;
                t2a:add_offset = 0.988291258275906 ;
                t2a:_FillValue = -32767s ;
                t2a:missing_value = -32767s ;
                t2a:units = "K" ;
                t2a:long_name = "2 metre temperature anomaly" ;

Example of Magics code : no need to specify that the data are geo-referenced nor to explicitly define the latitude and longitude variable names:

Netcdf Setting
data = mnetcdf(
               netcdf_filename ='netcdffile.nc'
               netcdf_time_dimension_setting = "2017-10-02 00:00:00", #extract the specified time 
               netcdf_value_variable = var
              )
anomaly = mcont(contour = "off",
                     legend = "on",
                     contour_shade = "on",
                     contour_level_selection_type = "level_list",
                     contour_level_list = [-15.00, -0.5, 0.5, 15.00],
                     contour_label = "off",
                     contour_label_height = 0.40,
                     contour_label_colour = "charcoal",
                     contour_label_frequency = 1,
                     contour_shade_method = "area_fill",
                     contour_shade_colour_method = "gradients",
                     contour_gradients_colour_list = ['blue','white','white', 'red'],
                     contour_gradients_step_list = [50, 1, 50]
                     )
plot(data, contour)

Introduced in 2.31.0

From this version, Magics can understand data represented in a projection different than the traditional latlon.The NetCDF header should just contain the proj4 string representing the projection used to describe the data. This is still a very early stage, but contact us if you are interested in such a functionality.

Example of metadata (ncdump):

ncdump
//Variables		
	   double x(x) ;
                x:standard_name = "projection_x_coordinate" ;
                x:long_name = "x coordinate of projection" ;
                x:units = "m" ;
        double y(y) ;
                y:standard_name = "projection_y_coordinate" ;
                y:long_name = "y coordinate of projection" ;
                y:units = "m" ;
	    float accumulation(duration, y, x) ;
                accumulation:long_name = "observed 24-hour rainfall accumulation" ;
                accumulation:_fillvalue = -9999.f ;
                accumulation:units = "mm" ;
                accumulation:grid_mapping = "lambert_azimuthal_equal_area" ;
// global attributes:
                :datatype = "operaGrid" ;
                :time = "09/01/2017 12:00:00" ;
                :conventions = "CF-1.5" ;
                :projection = "+proj=laea +lat_0=55.0 +lon_0=10.0 +x_0=1950000.0 +y_0=-2100000.0 +units=m +ellps=WGS84" ;
                :grid_corners = -10.4345768386404, 31.7462153193251, -39.5357864125034, 67.0228327583087, 57.8119647501499, 
								67.6210371027505, 29.421038635578, 31.987650277945 ;
Quick links :

Gallery: