Skip to content

Commit

Permalink
improve config and nc
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshempelmann committed Dec 9, 2018
1 parent 5c9eba0 commit 29a6ddc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion eggshell/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def top_level(self):
@property
def data(self):
"""Return the path to the data directory."""
return join(self.top_level, 'data')
return join(self._base, 'data')

@property
def shapefiles(self):
Expand Down
15 changes: 4 additions & 11 deletions eggshell/nc/nc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,16 @@ def opendap_or_download(resource, auth_tkt_cookie={}, output_path=None,
try:
nc = Dataset(output_file, 'r')
nc.close()
except:
except Exception:
raise IOError("This does not appear to be a valid NetCDF file.")
return output_file
return resource


def get_variable(resource):
"""
detects processable variable name in netCDF file
based on ocgis (compare guess_main_variables)
:param resource: filepath sting or sorted list for netcdf file(s)
:returns str: variable name
"""
rds = RequestDataset(resource)
return rds.variable
""" Moved to ocg_utils"""
from eggshell.nc.ocg_utils import get_variable as gv
return gv(resource)


def guess_main_variables(ncdataset):
Expand Down
17 changes: 14 additions & 3 deletions eggshell/nc/ocg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ def call(resource=[], variable=None, dimension_map=None, agg_selection=True, cal
import uuid

# prepare the environment
env.DIR_SHPCABINET = paths.shapefiles
env.OVERWRITE = True
# env.DIR_OUTPUT = dir_output
# LOGGER.debug(' **** env.DIR_OUTPUT = %s ' % env.DIR_OUTPUT)

if dir_output is None:
dir_output = abspath(curdir)
Expand Down Expand Up @@ -395,6 +392,20 @@ def calc_grouping(grouping):
raise Exception(msg)
return calc_grouping


def get_variable(resource):
"""
detects processable variable name in netCDF file
based on ocgis (compare guess_main_variables)
:param resource: filepath sting or sorted list for netcdf file(s)
:returns str: variable name
"""
rds = RequestDataset(resource)
return rds.variable


# def has_variable(resource, variable):
# """Check if resource has variable.
#
Expand Down

0 comments on commit 29a6ddc

Please sign in to comment.