Skip to content

Commit

Permalink
docs: slimmer build to prevent overutilization (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutterley committed Dec 9, 2022
1 parent 472a8c1 commit c24d764
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
14 changes: 10 additions & 4 deletions geoid_toolkit/spatial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
spatial.py
Written by Tyler Sutterley (10/2022)
Written by Tyler Sutterley (12/2022)
Utilities for reading, writing and operating on spatial data
Expand All @@ -20,6 +20,7 @@
UPDATE HISTORY:
Updated 12/2022: add software information to output HDF5 and netCDF4
place netCDF4 import within try/except statements
Updated 10/2022: added datetime parser for ascii time columns
Updated 06/2022: added field_mapping options to netCDF4 and HDF5 reads
added from_file wrapper function to read from particular formats
Expand Down Expand Up @@ -53,25 +54,30 @@
import uuid
import yaml
import logging
import netCDF4
import datetime
import warnings
import numpy as np
import dateutil.parser
import geoid_toolkit.version
from geoid_toolkit.utilities import get_git_revision_hash
# attempt imports
try:
import h5py
except (ImportError, ModuleNotFoundError) as e:
warnings.filterwarnings("always")
warnings.warn("h5py not available")
warnings.warn("Some functions will throw an exception if called")
try:
import osgeo.gdal, osgeo.osr, osgeo.gdalconst
except (ImportError, ModuleNotFoundError) as e:
warnings.filterwarnings("always")
warnings.warn("GDAL not available")
warnings.warn("Some functions will throw an exception if called")
try:
import h5py
import netCDF4
except (ImportError, ModuleNotFoundError) as e:
warnings.filterwarnings("always")
warnings.warn("h5py not available")
warnings.warn("netCDF4 not available")
warnings.warn("Some functions will throw an exception if called")
# ignore warnings
warnings.filterwarnings("ignore")
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
gdal
h5py
lxml
matplotlib
netCDF4
numpy
pyproj
python-dateutil
13 changes: 12 additions & 1 deletion scripts/read_EGM2008_geoid_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,29 @@
UPDATE HISTORY:
Updated 12/2022: single implicit import of geoid toolkit
place netCDF4 import within try/except statements
Written 06/2022
"""
from __future__ import print_function

import os
import logging
import netCDF4
import argparse
import datetime
import warnings
import numpy as np
import geoid_toolkit as geoidtk

# attempt imports
try:
import netCDF4
except (ImportError, ModuleNotFoundError) as e:
warnings.filterwarnings("always")
warnings.warn("netCDF4 not available")
warnings.warn("Some functions will throw an exception if called")
# ignore warnings
warnings.filterwarnings("ignore")

def read_EGM2008_geoid_grids(FILE, FILENAME=None, LOVE=0.3,
VERBOSE=False, MODE=0o775):

Expand Down
13 changes: 12 additions & 1 deletion scripts/read_ICGEM_geoid_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
UPDATE HISTORY:
Updated 12/2022: single implicit import of geoid toolkit
place netCDF4 import within try/except statements
Updated 05/2022: use argparse descriptions within sphinx documentation
Updated 04/2022: include utf-8 encoding in reads to be windows compliant
check if gravity field data file is present in file-system
Expand All @@ -43,12 +44,22 @@
import os
import re
import logging
import netCDF4
import argparse
import datetime
import warnings
import numpy as np
import geoid_toolkit as geoidtk

# attempt imports
try:
import netCDF4
except (ImportError, ModuleNotFoundError) as e:
warnings.filterwarnings("always")
warnings.warn("netCDF4 not available")
warnings.warn("Some functions will throw an exception if called")
# ignore warnings
warnings.filterwarnings("ignore")

# PURPOSE: Reads .gdf grids from the GFZ calculation service
def read_ICGEM_geoid_grids(FILE, FILENAME=None, MARKER='', SPACING=None,
VERBOSE=False, MODE=0o775):
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def check_output(cmd):
except Exception as e:
log.warning('Failed to get options via gdal-config')
else:
log.info(f"GDAL version from via gdal-config: {0}gdal_output[3]")
log.info(f"GDAL version from via gdal-config: {gdal_output[3]}")
# if setting GDAL version from via gdal-config
if gdal_output[3]:
if gdal_output[3] and ('gdal' in install_requires):
# add version information to gdal in install_requires
gdal_index = install_requires.index('gdal')
install_requires[gdal_index] = f'gdal=={gdal_output[3]}'
elif any(install_requires):
elif any(install_requires) and ('gdal' in install_requires):
# gdal version not found
gdal_index = install_requires.index('gdal')
install_requires.pop(gdal_index)
Expand All @@ -66,7 +66,7 @@ def check_output(cmd):
else:
log.info(f"HDF5 version from via h5dump: {hdf5_version}")
# if the HDF5 version not found
if not any(hdf5_output) and any(install_requires):
if not any(hdf5_output) and ('h5py' in install_requires):
hdf5_index = install_requires.index('h5py')
install_requires.pop(hdf5_index)

Expand Down

0 comments on commit c24d764

Please sign in to comment.