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

fixed imports to account for new repo structure

parent 6afb4379
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ import numpy as np
import xarray as xr
import ancillary_data as anc
import utils
import mvcm.utils as utils
from numpy.lib.stride_tricks import sliding_window_view
from typing import Dict
......
......@@ -15,7 +15,8 @@ _RTD = 180./np.pi
_bad_data = -999.0
_datapath = '/ships19/hercules/pveglio/mvcm_test_data'
logging.basicConfig(level=logging.INFO, format='%(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger('__name__')
# logging.basicConfig(level=logging.INFO, format='%(name)s - %(levelname)s - %(message)s')
# logging.basicConfig(level=logging.INFO, filename='logfile.log', 'filemode='w',
# format='%(name)s %(levelname)s %(message)s')
......@@ -93,7 +94,7 @@ class ReadData(CollectInputs):
sensor: str = field(validator=[validators.instance_of(str),
validators.in_(['viirs'])])
logging.debug('Instance of ReadData created')
logger.debug('Instance of ReadData created')
def read_viirs_geo(self) -> xr.Dataset:
"""Read VIIRS geolocation data and generate additional angles
......@@ -108,7 +109,7 @@ class ReadData(CollectInputs):
geo_data xarray.Dataset
dataset containing all geolocation data
"""
logging.debug(f'Reading {self.file_name_geo}')
logger.debug(f'Reading {self.file_name_geo}')
geo_data = xr.open_dataset(self.file_name_geo, group='geolocation_data')
relazi = self.relative_azimuth_angle(geo_data.sensor_azimuth.values, geo_data.solar_azimuth.values)
......@@ -120,7 +121,7 @@ class ReadData(CollectInputs):
geo_data['sunglint_angle'] = (self.dims, sunglint)
geo_data['scattering_angle'] = (self.dims, scatt_angle)
logging.debug('Geolocation file read correctly')
logger.debug('Geolocation file read correctly')
return geo_data
......@@ -135,7 +136,7 @@ class ReadData(CollectInputs):
solar_zenith: np.ndarray
solar zenith angle derived from the geolocation file
"""
logging.debug(f'Reading {self.file_name_l1b}')
logger.debug(f'Reading {self.file_name_l1b}')
l1b_data = xr.open_dataset(self.file_name_l1b, group='observation_data', decode_cf=False)
rad_data = xr.Dataset()
......@@ -154,7 +155,7 @@ class ReadData(CollectInputs):
else:
pass
logging.debug('L1b file read correctly')
logger.debug('L1b file read correctly')
return rad_data
......@@ -227,7 +228,7 @@ class ReadData(CollectInputs):
viirs.update(geo_data)
viirs = viirs.set_coords(['latitude', 'longitude'])
logging.debug('Viirs preprocessing completed successfully.')
logger.debug('Viirs preprocessing completed successfully.')
return viirs
def relative_azimuth_angle(self,
......@@ -248,7 +249,7 @@ class ReadData(CollectInputs):
"""
rel_azimuth = np.abs(180. - np.abs(sensor_azimuth - solar_azimuth))
logging.debug('Relative azimuth calculated successfully.')
logger.debug('Relative azimuth calculated successfully.')
return rel_azimuth
......@@ -276,7 +277,7 @@ class ReadData(CollectInputs):
cossna[cossna > 1] = 1
sunglint_angle = np.arccos(cossna) * _RTD
logging.debug('Sunglint generated')
logger.debug('Sunglint generated')
return sunglint_angle
......@@ -305,7 +306,7 @@ class ReadData(CollectInputs):
scatt_angle = np.arccos(cos_scatt_angle) * _RTD
logging.debug('Scattering angle calculated successfully')
logger.debug('Scattering angle calculated successfully')
return scatt_angle
......@@ -348,11 +349,11 @@ class ReadAncillary(CollectInputs):
array containing the Reynolds SST interpolated at the sensor's resolution
"""
if not os.path.isfile(os.path.join(self.ancillary_dir, self.sst_file)):
logging.error('SST file not found')
logger.error('SST file not found')
sst = np.empty(self.out_shape, dtype=np.float32).ravel()
sst = anc.py_get_Reynolds_SST(self.latitude.ravel(), self.longitude.ravel(), self.resolution,
self.ancillary_dir, self.sst_file, sst)
logging.debug('SST file read successfully')
logger.debug('SST file read successfully')
return sst.reshape(self.out_shape)
def get_ndvi(self) -> npt.NDArray[float]:
......@@ -367,11 +368,11 @@ class ReadAncillary(CollectInputs):
NDVI interpolated at the sensor's resolution
"""
if not os.path.isfile(os.path.join(self.ancillary_dir, self.ndvi_file)):
logging.error('NDVI file not found')
logger.error('NDVI file not found')
ndvi = np.empty(self.out_shape, dtype=np.float32).ravel()
ndvi = anc.py_get_NDVI_background(self.latitude.ravel(), self.longitude.ravel(), self.resolution,
self.ancillary_dir, self.ndvi_file, ndvi)
logging.debug('NDVI file read successfully')
logger.debug('NDVI file read successfully')
return ndvi.reshape(self.out_shape)
def get_eco(self) -> npt.NDArray[float]:
......@@ -388,7 +389,7 @@ class ReadAncillary(CollectInputs):
eco = np.empty(self.out_shape, dtype=np.ubyte).ravel()
eco = anc.py_get_Olson_eco(self.latitude.ravel(), self.longitude.ravel(), self.resolution,
self.ancillary_dir, eco)
logging.debug('Olson ecosystem file read successfully')
logger.debug('Olson ecosystem file read successfully')
return eco.reshape(self.out_shape)
def get_geos(self) -> Dict:
......@@ -403,15 +404,15 @@ class ReadAncillary(CollectInputs):
dictionary containing all quantities required by MVCM (see geos_variables here below)
"""
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_1)):
logging.error('GEOS-5 file 1 not found')
logger.error('GEOS-5 file 1 not found')
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_2)):
logging.error('GEOS-5 file 2 not found')
logger.error('GEOS-5 file 2 not found')
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_land)):
logging.error('GEOS-5 land file not found')
logger.error('GEOS-5 land file not found')
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_ocean)):
logging.error('GEOS-5 ocean file not found')
logger.error('GEOS-5 ocean file not found')
if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_constants)):
logging.error('GEOS-5 constants file not found')
logger.error('GEOS-5 constants file not found')
geos_variables = ['tpw', 'snow_fraction', 'ice_fraction', 'ocean_fraction',
'land_ice_fraction', 'surface_temperature']
......@@ -425,7 +426,7 @@ class ReadAncillary(CollectInputs):
for var in list(geos_variables):
geos_data[var] = geos_data[var].reshape(self.out_shape)
logging.debug('GEOS data read successfully')
logger.debug('GEOS data read successfully')
return geos_data
def pack_data(self) -> xr.Dataset:
......
......@@ -6,7 +6,7 @@ except ImportError:
# from glob import glob
import read_data as rd
import mvcm.read_data as rd
import ancillary_data as anc
# lsf: land sea flag
......
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