ts_smoke.py runs
[wrf-fire-matlab.git] / python / ts_smoke.py
blob64190ec04ea863dd89b3694306aa74b13313fdc5
1 import xarray as xr
2 import numpy as np
3 import sys
6 pm25_vars = []
7 times_vars = []
8 lon_vars = []
9 lat_vars = []
10 new = sys.argv[-1]
12 for file_path in sys.argv[1:-1]:
14 print('Reading NetCDF file',file_path)
15 ds = xr.open_dataset(file_path)
17 # read lowest layer
18 pm25_vars.append(ds["tr17_1"].isel(bottom_top=0))
20 # Get the other variables, Times, longitude, latitude
21 times_vars.append(ds["Times"])
22 lon_vars.append(ds["XLAT"])
23 lat_vars.append(ds["XLONG"])
25 print('Concatenating the data variables along the time dimension')
26 pm25 = xr.concat(pm25_vars, dim="Time")
27 times = xr.concat(times_vars, dim="Time")
28 lon = xr.concat(lon_vars, dim="Time")
29 lat = xr.concat(lat_vars, dim="Time")
31 del pm25_vars, times_vars, lon_vars, lat_vars
33 ds_new = xr.Dataset({'pm25':pm25,'times':times,'lon':lon,'lat':lat})
35 print('Creating new NetCDF file')
36 ds_new.to_netcdf(new)