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  Expand source
//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  Expand source
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  Expand source
//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:


 

netcdfdescriptiondefaultYour Selection
This handles the decoding of NetCDF Files.[version 3.1.0]
netcdf_typeType of data arrangement in the file (possible values: matrix) guess
netcdf_filenamePath of the file to be read
netcdf_dimension_settingExtract only of a subset of variables [ex: level:100:500] Enter a list of strings: val1/val2/val3stringarray()
netcdf_time_dimension_settingExtract only the specified times : date specified in Human readable format YYY-MM-DD HH:MM:00
netcdf_level_dimension_settingExtract only the specified level
netcdf_number_dimension_settingExtract only the specified number
netcdf_dimension_setting_methodMethod used to specify how to interpret the extraction of a subset, the range can by specified by value or by index value
netcdf_latitude_variableVariable name representing the latitude dimension latitude
netcdf_longitude_variableVariable name representing the longitude dimension longitude
netcdf_speed_component_variableVariable name representing the speed component of the vector
netcdf_direction_component_variableVariable name representing the direction component of the vector
netcdf_value_variableVariable to plot
netcdf_x_component_variablex_component for vector plotting
netcdf_y_component_variabley_component for vector plotting
netcdf_colour_component_variableVariable name representing the colour component of the vector ( in case of coloured wind)
netcdf_field_automatic_scalingApply an automatic scaling, if needed on
netcdf_field_scaling_factorScaling factor to multiply the field value by 1
netcdf_field_add_offsetOffset added to the field values 0
netcdf_missing_attributeAttribute indicating the value used to indicate a missing value in the data _FillValue
netcdf_field_suppress_belowValues in the input field(s) below this value are to be suppressed, i.e. not to be taken into consideration for plotting purposes -1.0e+21
netcdf_field_suppress_aboveValues in the input field(s) above this value are to be suppressed, i.e not to be taken into consideration for plotting purposes 1.0e+21
netcdf_x_variableVariable name for the x values x
netcdf_x2_variableVariable name for the auxiliary x values (used in CurveArea) x2
netcdf_y_variableVariable name for the y values y
netcdf_y2_variableVariable name for the auxiliary y values (used in CurveArea) y2
netcdf_x_auxiliary_variablevariable can used to define geoline definition.
netcdf_x_geoline_conventionGeoline Convention used lonlat or latlon lonlat
netcdf_y_geoline_conventionGeoline Convention used lonlat or latlon lonlat
netcdf_y_auxiliary_variablevariable can used to define geoline definition.
netcdf_matrix_primary_indexPrimary index latitude/longitude longitude
netcdf_metadataJson string containing metadata information: useful to choose a style {}