Beispiel #1
0
import xarray as xr
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from NO2 import helper_functions, open_data
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score

if __name__ == "__main__":
    # Load monthly NOx
    nox, pres_nox = open_data.load_osiris_nox_monthly(start_date='20050101',
                                                      end_date='20141231',
                                                      min_lat=-10,
                                                      max_lat=10,
                                                      pressure=1)

    # Load N2O
    datafile = xr.open_mfdataset(
        '/home/kimberlee/Masters/NO2/MLS_N2O_monthlymeans/MLS-N2O-*.nc')
    datafile = datafile.sel(Time=slice('20050101', '20141231'))
    no2 = datafile.N2O.where((datafile.Latitude > -10)
                             & (datafile.Latitude < 10))
    monthlymeans = no2.groupby('Time.month').mean('Time')
    anomalies_n2o = no2.groupby('Time.month') - monthlymeans
    anomalies_n2o['nLevels'] = datafile.Pressure.mean('Time')
    anomalies_n2o *= 1e9  # ppbv
    anomalies_n2o = anomalies_n2o[:, 5:
                                  15]  # corresponds to range of pressures returned by alt_to_pres

    # Put NOx on MLS pressure levels to match HNO3
    nox_on_pres_levels = np.zeros(
Beispiel #2
0
winds = xr.DataArray(file1, coords=[heights, time], dims=['heights', 'time'])
w1 = winds.sel(time=slice('2005-01-01', '2007-09-01'))  # nov 2005
w2 = winds.sel(time=slice('2007-01-01', '2009-09-01'))  # nov 2007
w3 = winds.sel(time=slice('2009-08-01', '2012-04-01'))  # jun 2010
w4 = winds.sel(time=slice('2011-10-01', '2014-06-01'))  # sep 2012

wavr = np.zeros(np.shape(w1))
for i in range(len(w1.time)):
    for j in range(len(w1.heights)):
        wavr[j, i] = np.mean([
            w1.values[j, i], w2.values[j, i], w3.values[j, i], w4.values[j, i]
        ])

# load NOx data
nox = open_data.load_osiris_nox_monthly(start_date='20050101',
                                        end_date='20141231',
                                        min_lat=-5,
                                        max_lat=5)
monthlymeans = nox.groupby('time.month').mean('time')
anomalies = nox.groupby('time.month') - monthlymeans

oz1 = anomalies.sel(time=slice('2005-01-01', '2007-08-01')).values  # nov 2005
oz2 = anomalies.sel(time=slice('2007-01-01', '2009-08-01')).values  # nov 2007
oz3 = anomalies.sel(time=slice('2009-08-01', '2012-03-01')).values  # jun 2010
oz4 = anomalies.sel(time=slice('2011-10-01', '2014-05-01')).values  # sep 2012

wavr_oz = np.zeros(np.shape(oz1))
for i in range(32):
    for j in range(30):
        wavr_oz[i,
                j] = np.nanmean([oz1[i, j], oz2[i, j], oz3[i, j], oz4[i, j]])