for var in odvars: print(var) data = reader.read_var(var, start=start, ts_type=freq) if not data.ts_type == 'monthly': data = data.resample_time('monthly') loaded.append(data) print('Regrid median SS to Noresm res.') first = loaded[0] medss = medss.regrid(first) medss.time.units = first.time.units medss.time.points = first.time.points medss.time.attributes = first.time.attributes medss.time.standard_name = first.time.standard_name for data in loaded: print('Adding', data.var_name) added = pya.io.aux_read_cubes.add_cubes(medss.cube, data.cube) medss = pya.GriddedData(added) medss.var_name = 'od550aer' medss.cube.attributes = {} medss.cube.attributes['data_id'] = OUT_ID medss.cube.attributes['ts_type'] = 'monthly' print(medss.time_stamps()) medss.to_netcdf(outdir, vert_code='Column')
"data settings. These will be unified using the " "metadata dictionary of the first cube " "(otherwise the method concatenate of the iris " "package won't work)".format(var_name)) for cube in cubes: cube.metadata = meta_init #now put the CubeList together and form one cube #1st equalise the cubes (remove non common attributes) equalise_attributes(cubes) #unify time units iris.util.unify_time_units(cubes) #now concatenate the cube list to one cube cubes_concat = iris._concatenate.concatenate(cubes, error_on_mismatch) return cubes_concat[0] if __name__== "__main__": import pyaerocom as pya ddir = '/lustre/storeA/project/aerocom/aerocom-users-database/SATELLITE-DATA/CALIOP3/renamed/' f1 = 'aerocom.CALIOP3.monthly.ec5323Ddust.2006.nc' fconv = pya.io.FileConventionRead(from_file=f1) cube = load_cube_custom(ddir + f1) print(cube) data = pya.GriddedData(cube) print(data.start) print(data.stop) print(data)
'standard_name'] = 'atmosphere_hybrid_sigma_pressure_coordinate' if ds.lev.data[0] == ds.lev.data[1]: OK = False issues.append('Level values not strictly monotonic') lev_vals = np.arange(len(ds.lev.data)) ds.lev.data = lev_vals if not OK: file = file.split('.nc')[0] + '_CORR.nc' ds.to_netcdf(file) return (file, OK, issues) for file in glob.glob('*CORR.nc'): os.remove(file) file = glob.glob('aerocom3_Oslo*monthly.nc')[0] print(file) (file, OK, issues) = check_file_okay(file) d = pya.GriddedData(file, var_name='ec550aer') print(d) if len(issues) > 0: print('------------------------------------------') print('Detected following issues:') for issue in issues: print(issue)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 7 13:35:07 2018 @author: jonasg """ import pyaerocom from pandas import Timestamp import numpy as np if __name__ == "__main__": data = pyaerocom.GriddedData() data._init_testdata_default() start = Timestamp("2018-1-22") stop = Timestamp("2018-2-5") lons = np.linspace(-10, 30, 20) lats = np.linspace(40, 80, 20) data = data.crop(lon_range=(lons[0], lons[-1]), lat_range=(lats[0], lats[-1]), time_range=(start, stop)) fig = data.quickplot_map() fig.suptitle("CROPPED") sample_points = [("longitude", lons), ("latitude", lats)] coords_avail = data.coords_order
d21 = iris.load(d2 + f21) d22 = iris.load(d2 + f22) d23 = iris.load(d2 + f23) data = [d11, d12, d21, d22, d23] #reader = pya.io.ReadGridded('TM5_AP3-INSITU') #dat = reader.read_var('vmrch4') for i, cubes in enumerate(data): print('At iter {}'.format(i)) for d in cubes: print('\n') print(d.var_name) print(d.shape) print(d.ndim) print([c.standard_name for c in d.dim_coords]) print([c.var_name for c in d.dim_coords]) print('\n\n') print(d11) ds11 = xarray.open_dataset(d1 + f11) ds21 = xarray.open_dataset(d2 + f21) data11 = pya.GriddedData(d1 + f11, var_name='abs5503Daer') data21 = pya.GriddedData(d2 + f21, var_name='vmrch4') print(ds21)
for var_name, vc in zip(varlist, vclist): outname = pya.io.helpers.aerocom_savename(data_id, var_name, vc, year, TS_TYPE) models = USE_MODELS if var_name in match_models: if year in match_models[var_name]: _year = match_models[var_name][year] outname_other = outname.replace(str(year), str(_year)) fp = os.path.join(OUT_DIR, outname_other) if not os.path.exists(fp): raise ValueError( f'Please process {_year} before {year}') data = pya.GriddedData(fp) models = data.metadata['from_models'] pya.const.print_log.info(f'\nPROCESSING {outname}\n') logfile.write('\n\n{}'.format(var_name)) if os.path.exists(os.path.join(OUT_DIR, outname)) and reanalyse_existing==False: pya.const.print_log.info('exists... -> skipping.') logfile.write(': SKIPPED') continue surf = vc=='Surface' comment = (f'AeroCom {avg_how} model data for variable ' f'{var_name}')
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 20 08:49:37 2018 @author: jonasg """ from matplotlib.colors import LogNorm import pyaerocom if __name__ == "__main__": data = pyaerocom.GriddedData()._init_testdata_default()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 11 09:55:03 2020 @author: jonasg """ import pyaerocom as pya import matplotlib.pyplot as plt plt.close('all') data_dir = '/lustre/storeA/project/fou/kl/CAMS61/CAMS_2018/EMEP/' data_file = 'EMEP_20180101_O3_0H24H.nc' data = pya.GriddedData(data_dir + data_file) data = data.extract_surface_level() data.metadata['ts_type'] = None # THIS WORKS NOW data.quickplot_map() # NOW CHECK PALEO DATE data.change_base_year(901) data.quickplot_map() print("ALL GOOD")
if __name__ == '__main__': pya.change_verbosity('critical') obs_reader = pya.io.ReadUngridded() obs = obs_reader.read(OBS_ID, OBS_VARS) model_reader = pya.io.ReadGridded(MODEL_ID_3D) model = model_reader.read_var(MODEL_VAR, start=YEAR) print(obs) print(model) model_at_stats = model.compute_at_stations_file(out_dir='out', obs_data=obs) model_reload = pya.GriddedData(model_at_stats) coll1 = pya.colocation.colocate_gridded_ungridded_2D(model, obs, 'monthly', var_ref='scatc550aer', vert_scheme='surface') coll2 = pya.colocation.colocate_gridded_ungridded_2D(model_reload, obs, 'monthly', var_ref='scatc550aer', vert_scheme='surface') coll1.plot_scatter()