def setUp(self):
        lats = np.array(range(-60, 61, 1))
        lons = np.array(range(-170, 171, 1))
        times = np.array([
            datetime.datetime(year, month, 1) for year in range(2000, 2010)
            for month in range(1, 13)
        ])
        values = np.ones([len(times), len(lats), len(lons)])
        self.target_dataset = ds.Dataset(lats,
                                         lons,
                                         times,
                                         values,
                                         variable="test variable name",
                                         units='test variable units',
                                         name='foo')

        self.spatial_out_of_bounds = ds.Bounds(-165, 165, -180, 180,
                                               datetime.datetime(2001, 1, 1),
                                               datetime.datetime(2004, 1, 1))

        self.temporal_out_of_bounds = ds.Bounds(-40, 40, -160.25, 160.5,
                                                datetime.datetime(1999, 1, 15),
                                                datetime.datetime(2222, 2, 15))

        self.everything_out_of_bounds = ds.Bounds(
            -165, 165, -180, 180, datetime.datetime(1999, 1, 15),
            datetime.datetime(2222, 2, 15))
    def setUp(self):
        self.target_dataset = ten_year_monthly_dataset()
        self.name = 'foo'

        self.subregion = ds.Bounds(-81, 81, -161, 161,
                                   datetime.datetime(2001, 1, 1),
                                   datetime.datetime(2004, 1, 1))
        self.non_exact_spatial_subregion = ds.Bounds(
            -80.25, 80.5, -160.25, 160.5, datetime.datetime(2001, 1, 1),
            datetime.datetime(2004, 1, 1))
        self.non_exact_temporal_subregion = ds.Bounds(
            -80.25, 80.5, -160.25, 160.5, datetime.datetime(2001, 1, 15),
            datetime.datetime(2004, 2, 15))
    def setUp(self):
        self.target_dataset = ten_year_monthly_dataset()
        self.target_dataset.lats = np.array(range(-89, 88, 2))
        self.target_dataset.lons = np.array(range(-179, 178, 2))

        self.subregion = ds.Bounds(-81, 81, -161, 161,
                                   datetime.datetime(2001, 1, 1),
                                   datetime.datetime(2004, 1, 1))
Exemple #4
0
    def setUp(self):
        self.target_dataset = ten_year_monthly_dataset()
        self.target_dataset.lats = np.array(range(-89, 88, 2))
        self.target_dataset.lons = np.array(range(-179, 178, 2))

        self.subregion = ds.Bounds(
            lat_min=-81, lat_max=81,
            lon_min=-161, lon_max=161,
            start=datetime.datetime(2001, 1, 1),
            end=datetime.datetime(2004, 1, 1)
        )
Exemple #5
0
    def setUp(self):
        self.target_dataset = ten_year_monthly_dataset()
        self.name = 'foo'

        self.subregion = ds.Bounds(
            lat_min=-81, lat_max=81,
            lon_min=-161, lon_max=161,
            start=datetime.datetime(2001, 1, 1),
            end=datetime.datetime(2004, 1, 1)
        )
        self.non_exact_spatial_subregion = ds.Bounds(
            lat_min=-80.25, lat_max=80.5,
            lon_min=-160.25, lon_max=160.5,
            start=datetime.datetime(2001, 1, 1),
            end=datetime.datetime(2004, 1, 1)
        )
        self.non_exact_temporal_subregion = ds.Bounds(
            lat_min=-80.25, lat_max=80.5,
            lon_min=-160.25, lon_max=160.5,
            start=datetime.datetime(2001, 1, 15),
            end=datetime.datetime(2004, 2, 15)
        )
Exemple #6
0
 def test_subset_without_start_index(self):
     self.subregion = ds.Bounds(
         lat_min=-81, lat_max=81,
         lon_min=-161, lon_max=161,
     )
     subset = dp.subset(self.target_dataset, self.subregion)
     times = np.array([datetime.datetime(year, month, 1)
                       for year in range(2000, 2010)
                       for month in range(1, 13)])
     self.assertEqual(subset.lats.shape[0], 82)
     self.assertSequenceEqual(list(np.array(range(-81, 82, 2))),
                              list(subset.lats))
     self.assertEqual(subset.lons.shape[0], 162)
     self.assertEqual(subset.values.shape, (120, 82, 162))
     self.assertEqual(subset.times.shape[0], 120)
     np.testing.assert_array_equal(subset.times, times)
# specific language governing permissions and limitations
# under the License.

import ocw.dataset as ds
import ocw.data_source.local as local
import ocw.dataset_processor as dsp
import ocw.plotter as plotter

import numpy as np
import numpy.ma as ma
''' data source: https://dx.doi.org/10.6084/m9.figshare.3753321.v1
    AOD_monthly_2000-Mar_2016-FEB_from_MISR_L3_JOINT.nc is publicly available.'''
dataset = local.load_file(
    'AOD_monthly_2000-MAR_2016-FEB_from_MISR_L3_JOINT.nc', 'nonabsorbing_ave')
''' Subset the data for East Asia'''
Bounds = ds.Bounds(lat_min=20, lat_max=57.7, lon_min=90, lon_max=150)
dataset = dsp.subset(dataset, Bounds)
'''The original dataset includes nonabsorbing AOD values between March 2000 and February 2015. 
dsp.temporal_subset will extract data in September-October-November.'''
dataset_SON = dsp.temporal_subset(dataset,
                                  month_start=9,
                                  month_end=11,
                                  average_each_year=True)

ny, nx = dataset_SON.values.shape[1:]

# multi-year mean aod
clim_aod = ma.zeros([3, ny, nx])

clim_aod[0, :] = ma.mean(dataset_SON.values, axis=0)  # 16-year mean
clim_aod[1, :] = ma.mean(dataset_SON.values[-5:, :],