Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.ascat_folder = os.path.join(os.path.dirname(__file__),
'..', 'test-data', 'sat',
'ascat', 'netcdf', '55R12')
self.ascat_grid_folder = os.path.join(os.path.dirname(__file__),
'..', 'test-data', 'sat',
'ascat', 'netcdf', 'grid')
# init the ASCAT_SSM reader with the paths
self.ascat_SSM_reader = ascat.AscatH25_SSM(self.ascat_folder,
self.ascat_grid_folder)
def setUp(self):
self.ascat_folder = os.path.join(os.path.dirname(__file__),
'..', 'test-data', 'sat',
'ascat', 'netcdf', '55R22')
self.ascat_grid_folder = os.path.join(os.path.dirname(__file__),
'..', 'test-data', 'sat',
'ascat', 'netcdf', 'grid')
# init the ASCAT_SSM reader with the paths
self.ascat_SSM_reader = ascat.AscatH25_SSM(self.ascat_folder,
self.ascat_grid_folder)
#
import pytesmo.io.sat.ascat as ascat
import pytesmo.time_series as ts
import os
import matplotlib.pyplot as plt
#
ascat_folder = os.path.join('R:\\','Datapool_processed','WARP','WARP5.5',
'ASCAT_WARP5.5_R1.2','080_ssm','netcdf')
ascat_grid_folder = os.path.join('R:\\','Datapool_processed','WARP','ancillary','warp5_grid')
#init the ASCAT_SSM reader with the paths
ascat_SSM_reader = ascat.AscatH25_SSM(ascat_folder,ascat_grid_folder)
#
ascat_ts = ascat_SSM_reader.read_ssm(45,0)
#plot soil moisture
ascat_ts.data['sm'].plot()
#
#calculate anomaly based on moving +- 17 day window
anomaly = ts.anomaly.calc_anomaly(ascat_ts.data['sm'], window_size=35)
anomaly.plot()
#
#calculate climatology
import pytesmo.scaling as scaling
import pytesmo.df_metrics as df_metrics
import pytesmo.metrics as metrics
import os
import matplotlib.pyplot as plt
ascat_folder = os.path.join('R:\\', 'Datapool_processed', 'WARP', 'WARP5.5',
'ASCAT_WARP5.5_R1.2', '080_ssm', 'netcdf')
ascat_grid_folder = os.path.join('R:\\', 'Datapool_processed', 'WARP', 'ancillary', 'warp5_grid')
# init the ASCAT_SSM reader with the paths
# let's not include the orbit direction since it is saved as 'A'
# or 'D' it can not be plotted
ascat_SSM_reader = ascat.AscatH25_SSM(ascat_folder, ascat_grid_folder,
include_in_df=['sm', 'sm_noise', 'ssf', 'proc_flag'])
# set path to ISMN data
path_to_ismn_data = os.path.join('D:\\', 'small_projects', 'cpa_2013_07_ISMN_userformat_reader', 'header_values_parser_test')
# Initialize reader
ISMN_reader = ismn.ISMN_Interface(path_to_ismn_data)
i = 0
label_ascat = 'sm'
label_insitu = 'insitu_sm'
# this loops through all stations that measure soil moisture
for station in ISMN_reader.stations_that_measure('soil moisture'):
if included in kwargs then all observations taken when
snow probability > mask_snow_prob are removed from the result
absolute_values : boolean, optional
if True soil porosities from HWSD and GLDAS will be used to
derive absolute values which will be available in the
pandas.DataFrame in the columns
'sm_por_gldas','sm_noise_por_gldas',
'sm_por_hwsd','sm_noise_por_hwsd'
Returns
-------
ASCATTimeSeries : object
:class:`pytesmo.io.sat.ascat.ASCATTimeSeries` instance
"""
df, gpi, lon, lat, cell, topo, wetland, porosity = super(
AscatH25_SSM, self)._read_ts(*args, **kwargs)
if 'mask_ssf' in kwargs:
mask_ssf = kwargs['mask_ssf']
if mask_ssf:
df = df[df['ssf'] == 1]
return ASCATTimeSeries(gpi, lon, lat, cell, df,
topo_complex=topo, wetland_frac=wetland,
porosity_gldas=porosity['gldas'],
porosity_hwsd=porosity['hwsd'])