Skip to content

Commit

Permalink
Include EGM96 geoid NetCDF file in Python library data. The file orig…
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Pechnikov committed Jun 3, 2024
1 parent 526656c commit 0f55208
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 34 deletions.
1 change: 1 addition & 0 deletions pygmtsar/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include pygmtsar/data/geoid_egm96_icgem.grd
30 changes: 0 additions & 30 deletions pygmtsar/pygmtsar/PRM_gmtsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,6 @@

class PRM_gmtsar:

@staticmethod
def gmtsar_sharedir():
"""
Get the location of the GMTSAR shared directory.
Returns
-------
str
The path to the GMTSAR shared directory.
Notes
-----
This method calls the GMTSAR tool 'gmtsar_sharedir.csh' to obtain the location of the GMTSAR shared directory.
The shared directory contains essential files and data used by GMTSAR.
"""
import os
import subprocess

argv = ['gmtsar_sharedir.csh']
p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf8')
stdout_data, stderr_data = p.communicate()

stderr_data = stderr_data.strip()
if stderr_data is not None and len(stderr_data):
print ('gmtsar_sharedir', stderr_data)
data = stdout_data.strip()
if data == '':
return stderr_data
return data

def calc_dop_orb(self, earth_radius=0, doppler_centroid=0, inplace=False, debug=False):
"""
Calculate the Doppler orbit.
Expand Down
6 changes: 3 additions & 3 deletions pygmtsar/pygmtsar/Stack_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def get_geoid(self, grid=None):
"""
import xarray as xr
import os
import importlib.resources as resources

gmtsar_sharedir = PRM().gmtsar_sharedir()
geoid_filename = os.path.join(gmtsar_sharedir, 'geoid_egm96_icgem.grd')
geoid = xr.open_dataarray(geoid_filename, engine=self.netcdf_engine, chunks=self.netcdf_chunksize).rename({'y': 'lat', 'x': 'lon'})
with resources.as_file(resources.files('pygmtsar.data') / 'geoid_egm96_icgem.grd') as geoid_filename:
geoid = xr.open_dataarray(geoid_filename, engine=self.netcdf_engine, chunks=self.netcdf_chunksize).rename({'y': 'lat', 'x': 'lon'})
if grid is not None:
geoid = geoid.interp_like(grid, method='cubic')
return geoid
Expand Down
2 changes: 1 addition & 1 deletion pygmtsar/pygmtsar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# Licensed under the BSD 3-Clause License (see LICENSE for details)
# ----------------------------------------------------------------------------
__version__ = '2024.4.17'
__version__ = '2024.6.3'

# unified progress indicators
from .tqdm_joblib import tqdm_joblib
Expand Down
Binary file added pygmtsar/pygmtsar/data/geoid_egm96_icgem.grd
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmtsar/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def get_version():
author_email='alexey@pechnikov.dev',
license='BSD-3-Clause',
packages=['pygmtsar'],
include_package_data=True,
package_data={
'pygmtsar': ['data/geoid_egm96_icgem.grd'],
},
install_requires=['xarray>=2024.1.0',
'numpy>=1.22.4',
'numba',
Expand Down

0 comments on commit 0f55208

Please sign in to comment.