-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc_aod.py
More file actions
24 lines (18 loc) · 854 Bytes
/
calc_aod.py
File metadata and controls
24 lines (18 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import xarray as xr
import numpy as np
import pandas as pd
import datetime
import matplotlib.pyplot as plt
# run = "00"
# run = run.zfill(2)
# today = datetime.date.today() #- datetime.timedelta(days=1)
# today_str = today.strftime("%Y%m%d")
def calc_aod(run, today_str, city, input_path):
ds_aod550 = xr.open_dataset(f'{input_path}/cams_AOD550_{today_str}{run}0000_{city}.grib', engine = 'cfgrib')
# Average values over all latitude and longitude to get a single value
# Grid spacing is different to the cloud cover product, so different strategy here
ds_aod550 = ds_aod550.mean(dim=['latitude', 'longitude'])
dust_aod550 = ds_aod550['duaod550'].values # Dat 1 to dat 2
total_aod550 = ds_aod550['aod550'].values
dust_aod550_ratio = dust_aod550/ total_aod550
return dust_aod550, total_aod550, dust_aod550_ratio