Skip to content
Snippets Groups Projects
Commit 4a568887 authored by Paolo Veglio's avatar Paolo Veglio
Browse files

initial template for testing read_data

parent d29519e7
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ cimport numpy as np
np.import_array()
ctypedef np.float_t DTYPE_t
DTYPE = np.float
DTYPE = np.float32
@cython.boundscheck(False)
@cython.wraparound(False)
......@@ -87,21 +87,21 @@ def py_get_GEOS(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, in
geos_data[v] = np.ascontiguousarray(geos_data[v])
cdef float[::1] tpw_mv = geos_data['tpw']
cdef float[::1] snowfr_mv = geos_data['snowfr']
cdef float[::1] icefr_mv = geos_data['icefr']
cdef float[::1] ocnfr_mv = geos_data['ocnfr']
cdef float[::1] landicefr_mv = geos_data['landicefr']
cdef float[::1] sfct_mv = geos_data['sfct']
cdef float[::1] snowfr_mv = geos_data['snow_fraction']
cdef float[::1] icefr_mv = geos_data['ice_fraction']
cdef float[::1] ocnfr_mv = geos_data['ocean_fraction']
cdef float[::1] landicefr_mv = geos_data['land_ice_fraction']
cdef float[::1] sfct_mv = geos_data['surface_temperature']
get_GEOS(&lat[0], &lon[0], res, startTime, anc_dir, geos1, geos2, geos_lnd, geos_ocn, geos_cnst,
&tpw_mv[0], &snowfr_mv[0], &icefr_mv[0], &ocnfr_mv[0], &landicefr_mv[0], &sfct_mv[0])
geos_dict = {'tpw': geos_data['tpw'],
'snowfr': geos_data['snowfr'],
'icefr': geos_data['icefr'],
'ocnfr': geos_data['ocnfr'],
'landicefr': geos_data['landicefr'],
'sfct': geos_data['sfct']
'snow_fraction': geos_data['snow_fraction'],
'ice_fraction': geos_data['ice_fraction'],
'ocean_fraction': geos_data['ocean_fraction'],
'land_ice_fraction': geos_data['land_ice_fraction'],
'surface_temperature': geos_data['surface_temperature']
}
return geos_dict
......
......@@ -18,3 +18,7 @@ classifiers = ['Programming Language :: Python :: 3',
[project.urls]
'Homepage' = 'https://gitlab.ssec.wisc.edu/pveglio/mvcm'
[tool.pytest.ini_options]
addopts = [
'--import-mode=importlib',
]
......@@ -13,7 +13,7 @@ from attrs import define, field, validators, Factory
_DTR = np.pi/180.
_RTD = 180./np.pi
_bad_data = -999.0
_datapath = '/ships19/hercules/pveglio/mvcm_viirs_hires'
_datapath = '/ships19/hercules/pveglio/mvcm_test_data'
logging.basicConfig(level=logging.INFO, format='%(name)s - %(levelname)s - %(message)s')
# logging.basicConfig(level=logging.INFO, filename='logfile.log', 'filemode='w',
......@@ -60,7 +60,7 @@ class CollectInputs(object):
validator=[validators.instance_of(str), ])
eco_file: str = field(default='goge1_2_img.v1',
validator=[validators.instance_of(str), ])
ndvi_file: str = field(default='NDVI.FM.c004.v2.0.WS.00-04-177.hdf',
ndvi_file: str = field(default='NDVI.FM.c004.v2.0.WS.00-04.177.hdf',
validator=[validators.instance_of(str), ])
geos_file_1: str = field(default='GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1200.V01.nc4',
validator=[validators.instance_of(str), ])
......@@ -402,15 +402,15 @@ class ReadAncillary(CollectInputs):
geos_data: Dict
dictionary containing all quantities required by MVCM (see geos_variables here below)
"""
if not os.path.isfile(os.path.join(self.ancillary, self.geos_file_1)):
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_1)):
logging.error('GEOS-5 file 1 not found')
if not os.path.isfile(os.path.join(self.ancillary, self.geos_file_2)):
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_2)):
logging.error('GEOS-5 file 2 not found')
if not os.path.isfile(os.path.join(self.ancillary, self.geos_land_file)):
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_land)):
logging.error('GEOS-5 land file not found')
if not os.path.isfile(os.path.join(self.ancillary, self.geos_ocean_file)):
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_ocean)):
logging.error('GEOS-5 ocean file not found')
if not os.path.isfile(os.path.join(self.ancillary, self.geos_constants_file)):
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_constants)):
logging.error('GEOS-5 constants file not found')
geos_variables = ['tpw', 'snow_fraction', 'ice_fraction', 'ocean_fraction',
......
......@@ -12,14 +12,14 @@ def fixturepath():
return os.path.join(os.path.dirname(__file__), 'fixtures')
# @pytest.fixture()
# def l1b_file(fixturepath):
# return os.path.join(fixturepath, '')
@pytest.fixture
def l1b_file():
return 'VNP02MOD.A2022173.1312.001.2022174011547.uwssec.nc'
# @pytest.fixture()
# def geo_file(fixturepath):
# return os.path.join(fixturepath, '')
@pytest.fixture
def geo_file():
return 'VNP03MOD.A2022173.1312.001.2022174012746.uwssec.nc'
# @pytest.fixture
......@@ -67,6 +67,18 @@ def ref_file(fixturepath):
return os.path.join(fixturepath, 'ref_ancillary.nc')
# this is only temporary. At some point I'll write a better test
def test_l1b(fixturepath, l1b_file, geo_file):
viirs = rd.ReadData(satellite='snpp',
sensor='viirs',
file_name_l1b=l1b_file,
file_name_geo=geo_file)
geo = viirs.read_viirs_geo()
l1b = viirs.read_l1b(geo.solar_zenith.values)
assert 'M11' in l1b.data_vars
def test_sst(fixturepath, sst_file, ref_file):
viirs = rd.ReadData(satellite='snpp',
sensor='viirs')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment