Command line executable to convert Marthe Grid file to netCDF
At the installation an executable ncmart is added to PATH and can be used to easily convert
a Marthe grid file to NetCDF format.
nb: the next commands are shell commands, the ‘!’ mark is only here for the python notebook version.
# how to use: print help message
!ncmart -h
usage: ncmart [-h] [--output OUTPUT] [--varname VARNAME] [--as2d]
[--xyfactor XYFACTOR] [--dump] [--attrs ATTRS] [--version]
[grid [timesteps] ...]
Convert a Marthe grid file to netCDF format.
positional arguments:
grid [timesteps] Paths to marthe grid and, optionally, timesteps files.
If gridfile is already a netCDF file, ncmart allows
you to modify it (with xyfactor, attrs, etc.).
options:
-h, --help show this help message and exit
--output OUTPUT, -o OUTPUT
Output filename. Default is input.nc
--varname VARNAME, -n VARNAME
Variable Name (field) to read, default is None: i.e
variable will be parsed from file and ONLY the first
variable will be read. Pass 'all' to get all
variables.
--as2d, -d Store grid as 2D (or more), default is 1D for space
dimension, ie reduced horizontal grid
--xyfactor XYFACTOR, -x XYFACTOR
Transformation factor for coordinates. Optional,
default is 1 (no transformation).
--dump, -H Dump variables names, like ncdump -h FILE.
--attrs ATTRS, -a ATTRS
Add global attributes. Comma separated for multiple
attrs, = is the separator for key, value. Example: `-a
"references=RP-XXXXX-FR,toto=tata"`
--version, -v Show version and exit
gridmarthe Copyright (C) 2025 BRGM.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, see GNU General Public Lisence v3 for copying.
# minimal setup: call ncmart with a grid file and a timestep file
# this will write the output with input filename and 'nc' extension
!ncmart ./data/chasim_hallue.out ./data/hallue.pastp
# print variables headers and dimensions with netcdf/nco tools
!ncdump -h ./data/chasim_hallue.nc
netcdf chasim_hallue {
dimensions:
time = 205 ;
zone = 927 ;
variables:
double charge(time, zone) ;
charge:_FillValue = NaN ;
string charge:varname = "CHARGE" ;
string charge:units = "m" ;
charge:missing_value = 9999. ;
string charge:standard_name = "water_table_level" ;
string charge:long_name = "groundwater head" ;
float x(zone) ;
x:_FillValue = NaNf ;
string x:units = "meters" ;
string x:axis = "X" ;
string x:standard_name = "projection_x_coordinate" ;
string x:coverage_content_type = "coordinate" ;
float y(zone) ;
y:_FillValue = NaNf ;
string y:units = "meters" ;
string y:axis = "Y" ;
string y:standard_name = "projection_y_coordinate" ;
string y:coverage_content_type = "coordinate" ;
float dx(zone) ;
dx:_FillValue = NaNf ;
float dy(zone) ;
dy:_FillValue = NaNf ;
int64 time(time) ;
string time:units = "days since 1995-07-31 00:00:00" ;
string time:calendar = "proleptic_gregorian" ;
int zone(zone) ;
string zone:compress = "y x" ;
int izone(zone) ;
// global attributes:
string :conventions = "CF-1.10" ;
string :title = "Modélisation du bassin de la SOMME Nappe_Libre" ;
:marthe_grid_version = 9. ;
string :original_dimensions = "x,y,z [grids]: 53 54 1" ;
string :crs = "{\'crs_wkt\': \'PROJCRS[\"NTF (Paris) / Lambert zone II\",BASEGEOGCRS[\"NTF (Paris)\",DATUM[\"Nouvelle Triangulation Francaise (Paris)\",ELLIPSOID[\"Clarke 1880 (IGN)\",6378249.2,293.466021293627,LENGTHUNIT[\"metre\",1]]],PRIMEM[\"Paris\",2.5969213,ANGLEUNIT[\"grad\",0.0157079632679489]],ID[\"EPSG\",4807]],CONVERSION[\"Lambert zone II\",METHOD[\"Lambert Conic Conformal (1SP)\",ID[\"EPSG\",9801]],PARAMETER[\"Latitude of natural origin\",52,ANGLEUNIT[\"grad\",0.0157079632679489],ID[\"EPSG\",8801]],PARAMETER[\"Longitude of natural origin\",0,ANGLEUNIT[\"grad\",0.0157079632679489],ID[\"EPSG\",8802]],PARAMETER[\"Scale factor at natural origin\",0.99987742,SCALEUNIT[\"unity\",1],ID[\"EPSG\",8805]],PARAMETER[\"False easting\",600000,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8806]],PARAMETER[\"False northing\",2200000,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8807]]],CS[Cartesian,2],AXIS[\"easting (X)\",east,ORDER[1],LENGTHUNIT[\"metre\",1]],AXIS[\"northing (Y)\",north,ORDER[2],LENGTHUNIT[\"metre\",1]],USAGE[SCOPE[\"Engineering survey, topographic mapping.\"],AREA[\"France mainland onshore between 50.5 grads and 53.5 grads North (45°27\\\'N to 48°09\\\'N). Also used over all onshore mainland France.\"],BBOX[42.33,-4.87,51.14,8.23]],ID[\"EPSG\",27572]]\', \'semi_major_axis\': 6378249.2, \'semi_minor_axis\': 6356515.0, \'inverse_flattening\': 293.4660212936269, \'reference_ellipsoid_name\': \'Clarke 1880 (IGN)\', \'longitude_of_prime_meridian\': 2.5969213, \'prime_meridian_name\': \'Paris\', \'geographic_crs_name\': \'NTF (Paris)\', \'horizontal_datum_name\': \'Nouvelle Triangulation Francaise (Paris)\', \'projected_crs_name\': \'NTF (Paris) / Lambert zone II\', \'grid_mapping_name\': \'lambert_conformal_conic\', \'standard_parallel\': 52.0, \'longitude_of_central_meridian\': 0.0, \'false_easting\': 600000.0, \'false_northing\': 2200000.0}" ;
string :lon_resolution = "0.5" ;
string :lat_resolution = "0.5" ;
string :resolution_units = "metre" ;
:scale_factor = 1. ;
string :nested_grid = "False" ;
string :extend = "xymin : 596.75 2542.25; xymax: 622.75 2568.75" ;
string :period = "1995-2012" ;
string :frequency = "30 day(s)" ;
string :creation_date = "Created on 2025-12-09T16:23:33Z UTC" ;
string :comment = "Hydrogeological model created with MARTHE code (Thiery, D. 2020. Guidelines for MARTHE v7.8 computer code for hydro-systems modelling. report BRGM/RP-69660-FR)." ;
string :domain = "FR-France" ;
string :institution = "BRGM, French Geological Survey, Orléans, France" ;
}