Skip to content

Commit

Permalink
Add environment variable SATPY_ANCPATH for crefl composites
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Mar 28, 2016
1 parent ca71343 commit 3c53e53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions etc/composites/viirs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sensor=viirs
name=crefl_M05
standard_name=corrected_reflectance
compositor=satpy.composites.viirs.CorrectedReflectance
dem_filename=/Users/davidh/repos/git/polar2grid/viirs_crefl/CMGDEM.hdf
dem_filename=CMGDEM.hdf
prerequisites=M05,M_SENA,M_SENZ,M_SOLA,M_SOLZ
sensor=viirs
metadata=sunz_corrected
Expand All @@ -62,7 +62,7 @@ modifiers=sunz_correction
name=crefl_M04
standard_name=corrected_reflectance
compositor=satpy.composites.viirs.CorrectedReflectance
dem_filename=/Users/davidh/repos/git/polar2grid/viirs_crefl/CMGDEM.hdf
dem_filename=CMGDEM.hdf
prerequisites=M04,M_SENA,M_SENZ,M_SOLA,M_SOLZ
sensor=viirs
metadata=sunz_corrected
Expand All @@ -72,7 +72,7 @@ modifiers=sunz_correction
name=crefl_M03
standard_name=corrected_reflectance
compositor=satpy.composites.viirs.CorrectedReflectance
dem_filename=/Users/davidh/repos/git/polar2grid/viirs_crefl/CMGDEM.hdf
dem_filename=CMGDEM.hdf
prerequisites=M03,M_SENA,M_SENZ,M_SOLA,M_SOLZ
sensor=viirs
metadata=sunz_corrected
Expand All @@ -82,7 +82,7 @@ modifiers=sunz_correction
name=crefl_I01
standard_name=corrected_reflectance
compositor=satpy.composites.viirs.CorrectedReflectance
dem_filename=/Users/davidh/repos/git/polar2grid/viirs_crefl/CMGDEM.hdf
dem_filename=CMGDEM.hdf
prerequisites=I01,M_SENA,M_SENZ,M_SOLA,M_SOLZ
sensor=viirs
metadata=sunz_corrected
Expand Down
9 changes: 8 additions & 1 deletion satpy/composites/viirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import logging
from satpy.composites import CompositeBase, IncompatibleAreas
from satpy.projectable import Projectable, combine_info
from satpy.config import get_environ_ancpath
import numpy as np
from scipy.special import erf

Expand Down Expand Up @@ -156,9 +157,15 @@ def __init__(self, *args, **kwargs):
assuming TOA or sealevel options.
:param dem_filename: path to the ancillary 'averaged heights' file
default: CMGDEM.hdf
environment override: os.path.join(<SATPY_ANCPATH>, <CREFL_ANCFILENAME>)
:param dem_sds: variable name to load from the ancillary file
"""
self.dem_file = kwargs.pop("dem_filename", "CMGDEM.hdf")
dem_filename = kwargs.pop("dem_filename", os.environ.get("CREFL_ANCFILENAME", "CMGDEM.hdf"))
if os.path.exists(dem_filename):
self.dem_file = dem_filename
else:
self.dem_file = os.path.join(get_environ_ancpath(), dem_filename)
self.dem_sds = kwargs.pop("dem_sds", "averaged elevation")
super(CorrectedReflectance, self).__init__(*args, **kwargs)

Expand Down
4 changes: 4 additions & 0 deletions satpy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def get_environ_config_dir(default=PACKAGE_CONFIG_PATH):
return os.environ.get('PPP_CONFIG_DIR', default)


def get_environ_ancpath(default='.'):
return os.environ.get('SATPY_ANCPATH', default)


# FIXME: Old readers still use only this, but this may get updated by Scene
CONFIG_PATH = get_environ_config_dir()

Expand Down

0 comments on commit 3c53e53

Please sign in to comment.