Exemplo n.º 1
0
def test_swi_ts_reader():
    """
    Test SWI time series reader.
    """
    data_path = os.path.join(os.path.dirname(__file__), 'ascat_test_data',
                             'cglops', 'swi_ts')

    rd = SWI_TS(data_path)
    data = rd.read_ts(3002621, mask_frozen=False)
    data_sorted = data.sort_index()

    assert np.all(data_sorted.index == data.index)
    # just check if enough data is there
    reference_index = pd.date_range('20070101T12:00:00', '20161231T12:00:00')
    assert len(data) == len(reference_index)
    assert np.all(data_sorted.index == reference_index)

    lon, lat = rd.grid.gpi2lonlat(3002621)
    data = rd.read_ts(lon, lat, mask_frozen=False)
    data_sorted = data.sort_index()

    assert np.all(data_sorted.index == data.index)
    # just check if enough data is there
    reference_index = pd.date_range('20070101T12:00:00', '20161231T12:00:00')
    assert len(data) == len(reference_index)
    assert np.all(data_sorted.index == reference_index)
Exemplo n.º 2
0
def test_swi_ts_qflag_reading():
    data_path = os.path.join(os.path.dirname(__file__), 'test-data', 'sat',
                             'cglops', 'swi_ts')
    rd = SWI_TS(data_path, parameters=['SWI_001', 'QFLAG_001', 'SSF'])
    data = rd.read_ts(3002621, mask_frozen=True)
    # check if QFLAG is correctly read. It should have as many NaN values as
    # SWI
    assert len(data[data.loc[:, 'QFLAG_001'] != np.nan]) > 0
    assert (len(data[data.loc[:, 'QFLAG_001'] == np.nan]) == len(
        data[data.loc[:, 'SWI_001'] == np.nan]))
Exemplo n.º 3
0
#plot the data using pandas builtin plot functionality
#this time using a subplot for each variable in the DataFrame
ssm_data_masked.plot(subplots=False)
plt.show()

#plot raw and masked SSM data in one plot to compare them

ssm_data_raw.data['SSM'].plot(label='raw SSM data')
ssm_data_masked.data['SSM'].plot(label='masked SSM data')
plt.legend()
plt.show()


#read SWI data using the SWI_TS reader
ascat_SWI_reader=SWI_TS(path_to_ascat_swi_ts_data)
swi_data_raw = ascat_SWI_reader.read_ts(3002621)

#plot the data using pandas builtin plot functionality
swi_data_raw.plot()
plt.show()



#read SWI data using the Ascat_SWI reader
ascat_SWI_reader = Ascat_SWI(path_to_ascat_swi_data,path_to_grid_definition,advisory_flags_path = path_to_adv_flags)


#reads swi data nearest to this lon,lat coordinates
#without any additional keywords all unmasked T values and
#Quality flags will be read
swi_data_raw = ascat_SWI_reader.read_swi(lon,lat)