Search
AOD johan
import pyaerocom as pya
import matplotlib.pyplot as plt
import pandas as pd
from warnings import filterwarnings
filterwarnings('ignore')
pya.change_verbosity('critical', log=pya.const.print_log) # don't output warnings


import seaborn as sns
# Use seaborn style defaults and set the default figure size
#sns.set(rc={'figure.figsize':(11, 4)})
pya.__version__
'0.8.1.dev1'
pya.const.BASEDIR = './shared-ns1000k/inputs/pyaerocom-testdata'
Initiating directories for pyaerocom test dataset
pya.const.BASEDIR
'./shared-ns1000k/inputs/pyaerocom-testdata'
obs_reader = pya.io.ReadUngridded('AeronetSDAV3Lev2.daily')
print(obs_reader)
Dataset name: AeronetSDAV3Lev2.daily
Data directory: ./shared-ns1000k/inputs/pyaerocom-testdata/obsdata/Aeronet.SDA.V3L2.0.daily/renamed
Supported variables: ['od500gt1aer', 'od500lt1aer', 'od500aer', 'ang4487aer', 'od550aer', 'od550gt1aer', 'od550lt1aer']
Last revision: 20190920
obs_data = obs_reader.read(vars_to_retrieve='od550aer')
obs_data #displays data type
UngriddedData <networks: ['AeronetSDAV3Lev2.daily']; vars: ['od550aer']; instruments: ['sun_photometer'];No. of stations: 1227
DATA_ID = 'TM5_AP3-CTRL2019'
_model_data = pya.io.ReadGridded(DATA_ID)
model_data =  _model_data.read_var('od550aer', start=2010)
display(model_data)
pyaerocom.GriddedData
Grid data: <iris 'Cube' of atmosphere_optical_thickness_due_to_ambient_aerosol / (1) (time: 12; latitude: 90; longitude: 120)>
# Example accessing data
axes = obs_data['Leipzig']['od550aer']['2015':'2015']
axes.plot(style='.')
<matplotlib.axes._subplots.AxesSubplot at 0x7f9f316835f8>
col_data = pya.colocation.colocate_gridded_ungridded(model_data, 
                                                     obs_data, 
                                                     ts_type='monthly',
                                                     start=2010)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-28-385e2e5e98d1> in <module>
      2                                                      obs_data,
      3                                                      ts_type='monthly',
----> 4                                                      start=2010)

~/.local/lib/python3.7/site-packages/pyaerocom-0.8.1.dev1-py3.7.egg/pyaerocom/colocation.py in colocate_gridded_ungridded(gridded_data, ungridded_data, ts_type, start, stop, filter_name, regrid_res_deg, remove_outliers, vert_scheme, harmonise_units, var_ref, var_outlier_ranges, var_ref_outlier_ranges, update_baseyear_gridded, ignore_station_names, apply_time_resampling_constraints, min_num_obs, colocate_time, var_keep_outliers, var_ref_keep_outliers, **kwargs)
    483 
    484     #crop time
--> 485     gridded_data = gridded_data.crop(time_range=(start, stop))
    486 
    487     if regrid_res_deg is not None:

~/.local/lib/python3.7/site-packages/pyaerocom-0.8.1.dev1-py3.7.egg/pyaerocom/griddeddata.py in crop(self, lon_range, lat_range, time_range, region)
   1313                 logger.info("Cropping along time axis based on Timestamps")
   1314                 time_constraint = get_time_rng_constraint(*time_range)
-> 1315                 data = data.extract(time_constraint)
   1316             elif all(isinstance(x, int) for x in time_range):
   1317                 logger.info("Cropping along time axis based on indices")

/opt/conda/lib/python3.7/site-packages/iris/cube.py in extract(self, constraint)
   2270         # Cast the constraint into a proper constraint if it is not so already
   2271         constraint = iris._constraints.as_constraint(constraint)
-> 2272         return constraint.extract(self)
   2273 
   2274     def intersection(self, *args, **kwargs):

/opt/conda/lib/python3.7/site-packages/iris/_constraints.py in extract(self, cube)
    149 
    150         """
--> 151         resultant_CIM = self._CIM_extract(cube)
    152         slice_tuple = resultant_CIM.as_slice()
    153         result = None

/opt/conda/lib/python3.7/site-packages/iris/_constraints.py in _CIM_extract(self, cube)
    173         else:
    174             for coord_constraint in self._coord_constraints:
--> 175                 resultant_CIM = resultant_CIM & coord_constraint.extract(cube)
    176 
    177         return resultant_CIM

/opt/conda/lib/python3.7/site-packages/iris/_constraints.py in extract(self, cube)
    288                 r[i] = True
    289         else:
--> 290             r = np.array([call_func(cell) for cell in coord.cells()])
    291         if dims:
    292             cube_cim[dims[0]] = r

/opt/conda/lib/python3.7/site-packages/iris/_constraints.py in <listcomp>(.0)
    288                 r[i] = True
    289         else:
--> 290             r = np.array([call_func(cell) for cell in coord.cells()])
    291         if dims:
    292             cube_cim[dims[0]] = r

~/.local/lib/python3.7/site-packages/pyaerocom-0.8.1.dev1-py3.7.egg/pyaerocom/helpers.py in <lambda>(cell)
   1074                                         day=stop.day)
   1075 
-> 1076     return iris.Constraint(time=lambda cell: t_lower <= cell <= t_upper)
   1077 
   1078 if __name__=="__main__":

/opt/conda/lib/python3.7/site-packages/iris/coords.py in __ge__(self, other)
    393 
    394     def __ge__(self, other):
--> 395         return self.__common_cmp__(other, operator.ge)
    396 
    397     def __le__(self, other):

/opt/conda/lib/python3.7/site-packages/iris/coords.py in __common_cmp__(self, other, operator_method)
    368             else:
    369                 if hasattr(other, 'timetuple'):
--> 370                     raise TypeError('Cannot determine whether a point lies '
    371                                     'within a bounded region for '
    372                                     'datetime-like objects.')

TypeError: Cannot determine whether a point lies within a bounded region for datetime-like objects.