diff --git a/doc/source/api_reference/compute_LPET_elevations.rst b/doc/source/api_reference/compute_LPET_elevations.rst index 63f168ba..dbc1f238 100644 --- a/doc/source/api_reference/compute_LPET_elevations.rst +++ b/doc/source/api_reference/compute_LPET_elevations.rst @@ -4,7 +4,7 @@ compute_LPET_elevation.py - Calculates long-period equilibrium tides for an input file - Uses the summation of fifteen tidal spectral lines from [Cartwright1971]_ [Cartwright1973]_ -- Can read and write ascii, netCDF4, HDF5, parquet and geotiff formats +- Can read and write ascii, netCDF4, HDF5, (cloud optimized) geotiff and (geo)parquet formats `Source code`__ @@ -20,6 +20,14 @@ Calling Sequence :nodescription: :nodefault: + --format -F : @after + * ``'csv'``: ascii with comma-separated values + * ``'netCDF4'``: Network Common Data Format version 4 + * ``'HDF5'``: Hierarchical Data Format version 5 + * ``'GTiff'``: GeoTiff georeferenced raster imagery + * ``'cog'``: Cloud Optimized GeoTIFF + * ``'parquet'``: Apache (geo)parquet + --variables : @after * for csv files: the order of the columns within the file * for HDF5, netCDF4 and parquet files: time, y, x and data variable names diff --git a/doc/source/api_reference/compute_LPT_displacements.rst b/doc/source/api_reference/compute_LPT_displacements.rst index 3e9bdfbb..d22c9e6c 100644 --- a/doc/source/api_reference/compute_LPT_displacements.rst +++ b/doc/source/api_reference/compute_LPT_displacements.rst @@ -5,7 +5,7 @@ compute_LPT_displacements.py - Calculates radial pole load tide displacements for an input file following IERS Convention (2010) guidelines * `https://iers-conventions.obspm.fr/chapter7.php `_ -- Can read and write ascii, netCDF4, HDF5, parquet and geotiff formats +- Can read and write ascii, netCDF4, HDF5, (cloud optimized) geotiff and (geo)parquet formats `Source code`__ @@ -21,6 +21,14 @@ Calling Sequence :nodescription: :nodefault: + --format -F : @after + * ``'csv'``: ascii with comma-separated values + * ``'netCDF4'``: Network Common Data Format version 4 + * ``'HDF5'``: Hierarchical Data Format version 5 + * ``'GTiff'``: GeoTiff georeferenced raster imagery + * ``'cog'``: Cloud Optimized GeoTIFF + * ``'parquet'``: Apache (geo)parquet + --variables : @after * for csv files: the order of the columns within the file * for HDF5, netCDF4 and parquet files: time, y, x and data variable names diff --git a/doc/source/api_reference/compute_OPT_displacements.rst b/doc/source/api_reference/compute_OPT_displacements.rst index eda89fc0..d5d4d389 100644 --- a/doc/source/api_reference/compute_OPT_displacements.rst +++ b/doc/source/api_reference/compute_OPT_displacements.rst @@ -6,7 +6,7 @@ compute_OPT_displacements.py * `https://iers-conventions.obspm.fr/chapter7.php `_ * `ftp://tai.bipm.org/iers/conv2010/chapter7/opoleloadcoefcmcor.txt.gz `_ -- Can read and write ascii, netCDF4, HDF5, parquet and geotiff formats +- Can read and write ascii, netCDF4, HDF5, (cloud optimized) geotiff and (geo)parquet formats `Source code`__ @@ -22,6 +22,14 @@ Calling Sequence :nodescription: :nodefault: + --format -F : @after + * ``'csv'``: ascii with comma-separated values + * ``'netCDF4'``: Network Common Data Format version 4 + * ``'HDF5'``: Hierarchical Data Format version 5 + * ``'GTiff'``: GeoTiff georeferenced raster imagery + * ``'cog'``: Cloud Optimized GeoTIFF + * ``'parquet'``: Apache (geo)parquet + --variables : @after * for csv files: the order of the columns within the file * for HDF5, netCDF4 and parquet files: time, y, x and data variable names diff --git a/doc/source/api_reference/compute_SET_displacements.rst b/doc/source/api_reference/compute_SET_displacements.rst index 8942cf6a..a9009da0 100644 --- a/doc/source/api_reference/compute_SET_displacements.rst +++ b/doc/source/api_reference/compute_SET_displacements.rst @@ -5,7 +5,7 @@ compute_SET_displacements.py - Calculates radial solid Earth tide displacements for an input file following IERS Convention (2010) guidelines * `https://iers-conventions.obspm.fr/chapter7.php `_ -- Can read and write ascii, netCDF4, HDF5, parquet and geotiff formats +- Can read and write ascii, netCDF4, HDF5, (cloud optimized) geotiff and (geo)parquet formats `Source code`__ @@ -21,6 +21,14 @@ Calling Sequence :nodescription: :nodefault: + --format -F : @after + * ``'csv'``: ascii with comma-separated values + * ``'netCDF4'``: Network Common Data Format version 4 + * ``'HDF5'``: Hierarchical Data Format version 5 + * ``'GTiff'``: GeoTiff georeferenced raster imagery + * ``'cog'``: Cloud Optimized GeoTIFF + * ``'parquet'``: Apache (geo)parquet + --variables : @after * for csv files: the order of the columns within the file * for HDF5, netCDF4 and parquet files: time, y, x and data variable names diff --git a/doc/source/api_reference/compute_tidal_currents.rst b/doc/source/api_reference/compute_tidal_currents.rst index f83ba135..55b1b9ea 100644 --- a/doc/source/api_reference/compute_tidal_currents.rst +++ b/doc/source/api_reference/compute_tidal_currents.rst @@ -5,7 +5,7 @@ compute_tidal_currents.py - Calculates tidal currents for an input file following [Egbert2002]_ - Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Finite Element Solution (FES) models provided by AVISO -- Can read and write ascii, netCDF4, HDF5, parquet and geotiff formats +- Can read and write ascii, netCDF4, HDF5, (cloud optimized) geotiff and (geo)parquet formats `Source code`__ @@ -21,6 +21,14 @@ Calling Sequence :nodescription: :nodefault: + --format -F : @after + * ``'csv'``: ascii with comma-separated values + * ``'netCDF4'``: Network Common Data Format version 4 + * ``'HDF5'``: Hierarchical Data Format version 5 + * ``'GTiff'``: GeoTiff georeferenced raster imagery + * ``'cog'``: Cloud Optimized GeoTIFF + * ``'parquet'``: Apache (geo)parquet + --variables : @after * for csv files: the order of the columns within the file * for HDF5, netCDF4 and parquet files: time, y, x and data variable names diff --git a/doc/source/api_reference/compute_tidal_elevations.rst b/doc/source/api_reference/compute_tidal_elevations.rst index e4c5cde0..20f2b06b 100644 --- a/doc/source/api_reference/compute_tidal_elevations.rst +++ b/doc/source/api_reference/compute_tidal_elevations.rst @@ -6,7 +6,7 @@ compute_tidal_elevations.py - Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO -- Can read and write ascii, netCDF4, HDF5, parquet and geotiff formats +- Can read and write ascii, netCDF4, HDF5, (cloud optimized) geotiff and (geo)parquet formats `Source code`__ @@ -22,6 +22,14 @@ Calling Sequence :nodescription: :nodefault: + --format -F : @after + * ``'csv'``: ascii with comma-separated values + * ``'netCDF4'``: Network Common Data Format version 4 + * ``'HDF5'``: Hierarchical Data Format version 5 + * ``'GTiff'``: GeoTiff georeferenced raster imagery + * ``'cog'``: Cloud Optimized GeoTIFF + * ``'parquet'``: Apache (geo)parquet + --variables : @after * for csv files: the order of the columns within the file * for HDF5, netCDF4 and parquet files: time, y, x and data variable names diff --git a/doc/source/api_reference/spatial.rst b/doc/source/api_reference/spatial.rst index 2fdf0d83..2fb5fb07 100644 --- a/doc/source/api_reference/spatial.rst +++ b/doc/source/api_reference/spatial.rst @@ -4,6 +4,8 @@ spatial Utilities for reading, writing and operating on spatial data + - Can read netCDF4, HDF5, (cloud optimized) geotiff or (geo)parquet files + Calling Sequence ---------------- diff --git a/pyTMD/spatial.py b/pyTMD/spatial.py index ea6276a1..c21a5152 100644 --- a/pyTMD/spatial.py +++ b/pyTMD/spatial.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" spatial.py -Written by Tyler Sutterley (07/2024) +Written by Tyler Sutterley (08/2024) Utilities for reading, writing and operating on spatial data @@ -30,6 +30,7 @@ crs.py: Coordinate Reference System (CRS) routines UPDATE HISTORY: + Updated 08/2024: changed from 'geotiff' to 'GTiff' and 'cog' formats Updated 07/2024: added functions to convert to and from DMS Updated 06/2024: added function to write parquet files with metadata Updated 05/2024: added function to read from parquet files @@ -195,7 +196,7 @@ def from_file(filename: str, format: str, **kwargs): dinput = from_netCDF4(filename, **kwargs) elif (format == 'HDF5'): dinput = from_HDF5(filename, **kwargs) - elif (format == 'geotiff'): + elif format in ('GTiff','cog'): dinput = from_geotiff(filename, **kwargs) elif (format == 'parquet'): dinput = from_parquet(filename, **kwargs) @@ -750,7 +751,7 @@ def to_file( to_netCDF4(output, attributes, filename, **kwargs) elif (format == 'HDF5'): to_HDF5(output, attributes, filename, **kwargs) - elif (format == 'geotiff'): + elif format in ('GTiff','cog'): to_geotiff(output, attributes, filename, **kwargs) elif (format == 'parquet'): to_parquet(output, attributes, filename, **kwargs) @@ -1083,7 +1084,7 @@ def to_geotiff( **kwargs ): """ - Write data to a geotiff file + Write data to a (cloud optimized) geotiff file Parameters ---------- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..1d4dd3b6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "setuptools_scm"] +build-backend = "setuptools.build_meta" diff --git a/scripts/compute_LPET_elevations.py b/scripts/compute_LPET_elevations.py index 0642177f..ecf28eb5 100644 --- a/scripts/compute_LPET_elevations.py +++ b/scripts/compute_LPET_elevations.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" compute_LPET_elevations.py -Written by Tyler Sutterley (07/2024) +Written by Tyler Sutterley (08/2024) Calculates long-period equilibrium tidal elevations for an input file INPUTS: @@ -17,7 +17,8 @@ netCDF4 HDF5 parquet - geotiff + GTiff + cog -v X, --variables X: variable names of data in csv, HDF5 or netCDF4 file for csv files: the order of the columns within the file for HDF5, netCDF4 and parquet files: time, y, x and data variable names @@ -69,6 +70,7 @@ predict.py: calculates long-period equilibrium ocean tides UPDATE HISTORY: + Updated 08/2024: changed from 'geotiff' to 'GTiff' and 'cog' formats Updated 07/2024: assert that data type is a known value Updated 06/2024: include attributes in output parquet files Updated 05/2024: use function to reading parquet files to allow @@ -171,7 +173,7 @@ def compute_LPET_elevations(input_file, output_file, dinput = pyTMD.spatial.from_HDF5(input_file, field_mapping=field_mapping) attributes = dinput['attributes'] - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): dinput = pyTMD.spatial.from_geotiff(input_file) attributes = dinput['attributes'] elif (FORMAT == 'parquet'): @@ -277,19 +279,20 @@ def compute_LPET_elevations(input_file, output_file, elif (FORMAT == 'HDF5'): # write to HDF5 pyTMD.spatial.to_HDF5(output, attrib, output_file) - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): # write raster data to geotiff # copy global geotiff attributes for projection and grid parameters for att_name in ['projection','wkt','spacing','extent']: attrib[att_name] = attributes[att_name] pyTMD.spatial.to_geotiff(output, attrib, output_file, - varname='tide_lpe') + varname='tide_lpe', driver=FORMAT) elif (FORMAT == 'parquet'): # write to (geo)parquet geoparquet = attributes.get('geoparquet', False) geometry_encoding = attributes.get('geometry_encoding', None) pyTMD.spatial.to_parquet(output, attrib, output_file, - geoparquet=geoparquet, geometry_encoding=geometry_encoding, crs=4326) + geoparquet=geoparquet, geometry_encoding=geometry_encoding, + crs=4326) # change the permissions level to MODE output_file.chmod(mode=MODE) @@ -313,7 +316,7 @@ def arguments(): # input and output data format parser.add_argument('--format','-F', type=str, default='csv', - choices=('csv','netCDF4','HDF5','geotiff','parquet'), + choices=('csv','netCDF4','HDF5','GTiff','cog','parquet'), help='Input and output data format') # variable names (for csv names of columns) parser.add_argument('--variables','-v', diff --git a/scripts/compute_LPT_displacements.py b/scripts/compute_LPT_displacements.py index 3cfaf8bb..1104aaf3 100644 --- a/scripts/compute_LPT_displacements.py +++ b/scripts/compute_LPT_displacements.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" compute_LPT_displacements.py -Written by Tyler Sutterley (07/2024) +Written by Tyler Sutterley (08/2024) Calculates radial load pole tide displacements for an input file following IERS Convention (2010) guidelines https://iers-conventions.obspm.fr/chapter7.php @@ -19,7 +19,8 @@ netCDF4 HDF5 parquet - geotiff + GTiff + cog -v X, --variables X: variable names of data in csv, HDF5 or netCDF4 file for csv files: the order of the columns within the file for HDF5, netCDF4 and parquet files: time, y, x and data variable names @@ -78,6 +79,7 @@ utilities.py: download and management utilities for syncing files UPDATE HISTORY: + Updated 08/2024: changed from 'geotiff' to 'GTiff' and 'cog' formats Updated 07/2024: assert that data type is a known value Updated 06/2024: include attributes in output parquet files Updated 05/2024: use function to reading parquet files to allow @@ -192,7 +194,7 @@ def compute_LPT_displacements(input_file, output_file, dinput = pyTMD.spatial.from_HDF5(input_file, field_mapping=field_mapping) attributes = dinput['attributes'] - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): dinput = pyTMD.spatial.from_geotiff(input_file) attributes = dinput['attributes'] elif (FORMAT == 'parquet'): @@ -350,19 +352,20 @@ def compute_LPT_displacements(input_file, output_file, elif (FORMAT == 'HDF5'): # write to HDF5 pyTMD.spatial.to_HDF5(output, attrib, output_file) - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): # write raster data to geotiff # copy global geotiff attributes for projection and grid parameters for att_name in ['projection','wkt','spacing','extent']: attrib[att_name] = attributes[att_name] pyTMD.spatial.to_geotiff(output, attrib, output_file, - varname='tide_pole') + varname='tide_pole', driver=FORMAT) elif (FORMAT == 'parquet'): # write to (geo)parquet geoparquet = attributes.get('geoparquet', False) geometry_encoding = attributes.get('geometry_encoding', None) pyTMD.spatial.to_parquet(output, attrib, output_file, - geoparquet=geoparquet, geometry_encoding=geometry_encoding, crs=4326) + geoparquet=geoparquet, geometry_encoding=geometry_encoding, + crs=4326) # change the permissions level to MODE output_file.chmod(mode=MODE) @@ -386,7 +389,7 @@ def arguments(): # input and output data format parser.add_argument('--format','-F', type=str, default='csv', - choices=('csv','netCDF4','HDF5','geotiff','parquet'), + choices=('csv','netCDF4','HDF5','GTiff','cog','parquet'), help='Input and output data format') # variable names (for csv names of columns) parser.add_argument('--variables','-v', diff --git a/scripts/compute_OPT_displacements.py b/scripts/compute_OPT_displacements.py index ebf61800..788dc4e1 100644 --- a/scripts/compute_OPT_displacements.py +++ b/scripts/compute_OPT_displacements.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" compute_OPT_displacements.py -Written by Tyler Sutterley (06/2024) +Written by Tyler Sutterley (08/2024) Calculates radial ocean pole load tide displacements for an input file following IERS Convention (2010) guidelines https://iers-conventions.obspm.fr/chapter7.php @@ -19,7 +19,8 @@ netCDF4 HDF5 parquet - geotiff + GTiff + cog -v X, --variables X: variable names of data in csv, HDF5 or netCDF4 file for csv files: the order of the columns within the file for HDF5, netCDF4 and parquet files: time, y, x and data variable names @@ -90,6 +91,7 @@ doi: 10.1007/s00190-015-0848-7 UPDATE HISTORY: + Updated 08/2024: changed from 'geotiff' to 'GTiff' and 'cog' formats Updated 06/2024: include attributes in output parquet files use np.clongdouble instead of np.longcomplex Updated 05/2024: use function to reading parquet files to allow @@ -211,7 +213,7 @@ def compute_OPT_displacements(input_file, output_file, dinput = pyTMD.spatial.from_HDF5(input_file, field_mapping=field_mapping) attributes = dinput['attributes'] - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): dinput = pyTMD.spatial.from_geotiff(input_file) attributes = dinput['attributes'] elif (FORMAT == 'parquet'): @@ -392,19 +394,20 @@ def compute_OPT_displacements(input_file, output_file, elif (FORMAT == 'HDF5'): # write to HDF5 pyTMD.spatial.to_HDF5(output, attrib, output_file) - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): # write raster data to geotiff # copy global geotiff attributes for projection and grid parameters for att_name in ['projection','wkt','spacing','extent']: attrib[att_name] = attributes[att_name] pyTMD.spatial.to_geotiff(output, attrib, output_file, - varname='tide_oc_pole') + varname='tide_oc_pole', driver=FORMAT) elif (FORMAT == 'parquet'): # write to (geo)parquet geoparquet = attributes.get('geoparquet', False) geometry_encoding = attributes.get('geometry_encoding', None) pyTMD.spatial.to_parquet(output, attrib, output_file, - geoparquet=geoparquet, geometry_encoding=geometry_encoding, crs=4326) + geoparquet=geoparquet, geometry_encoding=geometry_encoding, + crs=4326) # change the permissions level to MODE output_file.chmod(mode=MODE) @@ -428,7 +431,7 @@ def arguments(): # input and output data format parser.add_argument('--format','-F', type=str, default='csv', - choices=('csv','netCDF4','HDF5','geotiff','parquet'), + choices=('csv','netCDF4','HDF5','GTiff','cog','parquet'), help='Input and output data format') # variable names (for csv names of columns) parser.add_argument('--variables','-v', diff --git a/scripts/compute_SET_displacements.py b/scripts/compute_SET_displacements.py index f1b67e51..fda2decf 100644 --- a/scripts/compute_SET_displacements.py +++ b/scripts/compute_SET_displacements.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" compute_SET_displacements.py -Written by Tyler Sutterley (07/2024) +Written by Tyler Sutterley (08/2024) Calculates radial solid earth tide displacements for an input file following IERS Convention (2010) guidelines https://iers-conventions.obspm.fr/chapter7.php @@ -19,7 +19,8 @@ netCDF4 HDF5 parquet - geotiff + GTiff + cog -v X, --variables X: variable names of data in csv, HDF5 or netCDF4 file for csv files: the order of the columns within the file for HDF5, netCDF4 and parquet files: time, y, x and data variable names @@ -98,6 +99,7 @@ doi: 10.1111/j.1365-246X.1981.tb02690.x UPDATE HISTORY: + Updated 08/2024: changed from 'geotiff' to 'GTiff' and 'cog' formats Updated 07/2024: assert that data type is a known value Updated 06/2024: include attributes in output parquet files Updated 05/2024: use function to reading parquet files to allow @@ -191,7 +193,7 @@ def compute_SET_displacements(input_file, output_file, dinput = pyTMD.spatial.from_HDF5(input_file, field_mapping=field_mapping) attributes = dinput['attributes'] - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): dinput = pyTMD.spatial.from_geotiff(input_file) attributes = dinput['attributes'] elif (FORMAT == 'parquet'): @@ -351,19 +353,20 @@ def compute_SET_displacements(input_file, output_file, elif (FORMAT == 'HDF5'): # write to HDF5 pyTMD.spatial.to_HDF5(output, attrib, output_file) - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): # write raster data to geotiff # copy global geotiff attributes for projection and grid parameters for att_name in ['projection','wkt','spacing','extent']: attrib[att_name] = attributes[att_name] pyTMD.spatial.to_geotiff(output, attrib, output_file, - varname='tide_earth') + varname='tide_earth', driver=FORMAT) elif (FORMAT == 'parquet'): # write to (geo)parquet geoparquet = attributes.get('geoparquet', False) geometry_encoding = attributes.get('geometry_encoding', None) pyTMD.spatial.to_parquet(output, attrib, output_file, - geoparquet=geoparquet, geometry_encoding=geometry_encoding, crs=4326) + geoparquet=geoparquet, geometry_encoding=geometry_encoding, + crs=4326) # change the permissions level to MODE output_file.chmod(mode=MODE) @@ -387,7 +390,7 @@ def arguments(): # input and output data format parser.add_argument('--format','-F', type=str, default='csv', - choices=('csv','netCDF4','HDF5','geotiff','parquet'), + choices=('csv','netCDF4','HDF5','GTiff','cog','parquet'), help='Input and output data format') # variable names (for csv names of columns) parser.add_argument('--variables','-v', diff --git a/scripts/compute_tidal_currents.py b/scripts/compute_tidal_currents.py index a865a30e..687812d1 100755 --- a/scripts/compute_tidal_currents.py +++ b/scripts/compute_tidal_currents.py @@ -28,7 +28,8 @@ csv (default) netCDF4 HDF5 - geotiff + GTiff + cog --variables X: variable names of data in csv, HDF5 or netCDF4 file for csv files: the order of the columns within the file for HDF5, netCDF4 and parquet files: time, y, x and data variable names @@ -100,6 +101,7 @@ UPDATE HISTORY: Updated 08/2024: allow inferring only specific minor constituents added option to try automatic detection of definition file format + changed from 'geotiff' to 'GTiff' and 'cog' formats Updated 07/2024: assert that data type is a known value added option to crop to the domain of the input data added option to use JSON format definition files @@ -251,7 +253,7 @@ def compute_tidal_currents(tide_dir, input_file, output_file, dinput = pyTMD.spatial.from_HDF5(input_file, field_mapping=field_mapping) attributes = dinput['attributes'] - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): dinput = pyTMD.spatial.from_geotiff(input_file) attributes = dinput['attributes'] elif (FORMAT == 'parquet'): @@ -432,7 +434,7 @@ def compute_tidal_currents(tide_dir, input_file, output_file, elif (FORMAT == 'HDF5'): # write to HDF5 pyTMD.spatial.to_HDF5(output, attrib, output_file) - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): # write raster data to geotiff # copy global geotiff attributes for projection and grid parameters for att_name in ['projection','wkt','spacing','extent']: @@ -441,13 +443,14 @@ def compute_tidal_currents(tide_dir, input_file, output_file, output['data'] = np.concatenate((output['u'],output['v']),axis=-1) attrib['data'] = {'_FillValue':FILL_VALUE} pyTMD.spatial.to_geotiff(output, attrib, output_file, - varname='data') + varname='data', driver=FORMAT) elif (FORMAT == 'parquet'): # write to (geo)parquet geoparquet = attributes.get('geoparquet', False) geometry_encoding = attributes.get('geometry_encoding', None) pyTMD.spatial.to_parquet(output, attrib, output_file, - geoparquet=geoparquet, geometry_encoding=geometry_encoding, crs=4326) + geoparquet=geoparquet, geometry_encoding=geometry_encoding, + crs=4326) # change the permissions level to MODE output_file.chmod(mode=MODE) @@ -499,7 +502,7 @@ def arguments(): # input and output data format parser.add_argument('--format','-F', type=str, default='csv', - choices=('csv','netCDF4','HDF5','geotiff','parquet'), + choices=('csv','netCDF4','HDF5','GTiff','cog','parquet'), help='Input and output data format') # variable names (for csv names of columns) parser.add_argument('--variables','-v', @@ -558,7 +561,7 @@ def arguments(): help='Infer values for minor constituents') # specify minor constituents to infer parser.add_argument('--minor-constituents', - type=str, nargs='+', + metavar='MINOR', type=str, nargs='+', help='Minor constituents to infer') # fill value for output spatial fields parser.add_argument('--fill-value','-f', diff --git a/scripts/compute_tidal_elevations.py b/scripts/compute_tidal_elevations.py index 0d404edf..fd3a9f02 100755 --- a/scripts/compute_tidal_elevations.py +++ b/scripts/compute_tidal_elevations.py @@ -29,7 +29,8 @@ csv (default) netCDF4 HDF5 - geotiff + GTiff + cog --variables X: variable names of data in csv, HDF5 or netCDF4 file for csv files: the order of the columns within the file for HDF5, netCDF4 and parquet files: time, y, x and data variable names @@ -103,6 +104,7 @@ UPDATE HISTORY: Updated 08/2024: allow inferring only specific minor constituents added option to try automatic detection of definition file format + changed from 'geotiff' to 'GTiff' and 'cog' formats Updated 07/2024: assert that data type is a known value added option to crop to the domain of the input data added option to use JSON format definition files @@ -256,7 +258,7 @@ def compute_tidal_elevations(tide_dir, input_file, output_file, dinput = pyTMD.spatial.from_HDF5(input_file, field_mapping=field_mapping) attributes = dinput['attributes'] - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): dinput = pyTMD.spatial.from_geotiff(input_file) attributes = dinput['attributes'] elif (FORMAT == 'parquet'): @@ -432,19 +434,20 @@ def compute_tidal_elevations(tide_dir, input_file, output_file, elif (FORMAT == 'HDF5'): # write to HDF5 pyTMD.spatial.to_HDF5(output, attrib, output_file) - elif (FORMAT == 'geotiff'): + elif FORMAT in ('GTiff', 'cog'): # write raster data to geotiff # copy global geotiff attributes for projection and grid parameters for att_name in ['projection','wkt','spacing','extent']: attrib[att_name] = attributes[att_name] pyTMD.spatial.to_geotiff(output, attrib, output_file, - varname=output_variable) + varname=output_variable, driver=FORMAT) elif (FORMAT == 'parquet'): # write to (geo)parquet geoparquet = attributes.get('geoparquet', False) geometry_encoding = attributes.get('geometry_encoding', None) pyTMD.spatial.to_parquet(output, attrib, output_file, - geoparquet=geoparquet, geometry_encoding=geometry_encoding, crs=4326) + geoparquet=geoparquet, geometry_encoding=geometry_encoding, + crs=4326) # change the permissions level to MODE output_file.chmod(mode=MODE) @@ -496,7 +499,7 @@ def arguments(): # input and output data format parser.add_argument('--format','-F', type=str, default='csv', - choices=('csv','netCDF4','HDF5','geotiff','parquet'), + choices=('csv','netCDF4','HDF5','GTiff','cog','parquet'), help='Input and output data format') # variable names (for csv names of columns) parser.add_argument('--variables','-v', @@ -555,7 +558,7 @@ def arguments(): help='Infer values for minor constituents') # specify minor constituents to infer parser.add_argument('--minor-constituents', - type=str, nargs='+', + metavar='MINOR', type=str, nargs='+', help='Minor constituents to infer') # apply flexure scaling factors to height values parser.add_argument('--apply-flexure',