diff --git a/make_binned_heating.py b/make_binned_heating.py index bcb2779ef8f80f1e0e084d392b7737fedd21e017..e4ead7a9861f1e794469ba83d4792d13b3f5ba70 100644 --- a/make_binned_heating.py +++ b/make_binned_heating.py @@ -3,7 +3,6 @@ # # on IMG JET call with /jetfs/home/avoigt/micromamba/envs/cloudsat-calipso/bin/python3.12 make_binned_heating.py -import rioxarray as rxr import xarray as xr import numpy as np import pandas as pd @@ -112,4 +111,4 @@ for year in ["2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "20 da_hr_allsky_lw = xr.DataArray(hr_allsky[:,1], name="HR_allsky_lw", dims=("pentad", "height", "lat", "lon",), coords={"pentad": pents, "height": np.arange(0,125), "lat": lats, "lon": lons}) da_hr_clrsky_sw = xr.DataArray(hr_clrsky[:,0], name="HR_clrsky_sw", dims=("pentad", "height", "lat", "lon",), coords={"pentad": pents, "height": np.arange(0,125), "lat": lats, "lon": lons}) da_hr_clrsky_lw = xr.DataArray(hr_clrsky[:,1], name="HR_clrsky_lw", dims=("pentad", "height", "lat", "lon",), coords={"pentad": pents, "height": np.arange(0,125), "lat": lats, "lon": lons}) - xr.merge([da_hr_allsky_sw, da_hr_allsky_lw, da_hr_clrsky_sw, da_hr_clrsky_lw]).to_netcdf("2B-FLXHR-LIDAR.P2_R05.heatingrates_binned."+year+".nc") + xr.merge([da_hr_allsky_sw, da_hr_allsky_lw, da_hr_clrsky_sw, da_hr_clrsky_lw]).to_netcdf("/jetfs/scratch/avoigt/CLOUDSAT/2B-FLXHR-LIDAR.P2_R05.heatingrates_binned."+year+".nc") diff --git a/postprocess_binned_heating.py b/postprocess_binned_heating.py index 18076c0aea655c529cd7a5972515dc34ab6b785b..de1af51ee0af4e6013419961b46c14e967fc3ae3 100644 --- a/postprocess_binned_heating.py +++ b/postprocess_binned_heating.py @@ -20,10 +20,10 @@ height = core.read_height(file)["HGT"].mean("y") ds_list = list() for year in ["2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017"]: - ds = xr.open_dataset("/jetfs/home/avoigt/cloudsat-calipso-heating-rates/2B-FLXHR-LIDAR.P2_R05.heatingrates_binned."+year+".nc") + ds = xr.open_dataset("/jetfs/scratch/avoigt/CLOUDSAT/2B-FLXHR-LIDAR.P2_R05.heatingrates_binned."+year+".nc", chunks="auto") time = np.arange(year+"-01-03", year+"-12-31", 5, dtype='datetime64[D]') ds = ds.rename({"pentad": "time"}).assign_coords({"time": time}) - ds = ds.assign_coords({"height": height}) + ds = ds.assign_coords({"height": height.values}) ds = ds.assign_attrs({"Data": "Atmospheric radiative heating rates based on 2B-FLXHR-LIDAR.P2_R05"}) ds = ds.assign_attrs({"Data producer": "Aiko Voigt, Dept of Meteorology and Geophysics, University of Vienna"}) ds = ds.assign_attrs({"Time": "Data generated on April 5, 2024"}) @@ -32,11 +32,10 @@ for year in ["2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "20 "Data on the same height bins are averaged together. "\ "The height of the heights bins is defined as the mean height along a sample granule." ds = ds.assign_attrs({"Note on height coordinate": text}) - ds = ds.drop_vars("xfull") ds_list.append(ds) del ds # merge into one dataset and save to netcdf -ds_merged = xr.merge(ds_list) -ds_merged.to_netcdf("2B-FLXHR-LIDAR.P2_R05.heatingrates_binned.2006-2017.nc") +ds_merged = xr.concat(ds_list, "time") +ds_merged.to_netcdf("/jetfs/scratch/avoigt/CLOUDSAT/2B-FLXHR-LIDAR.P2_R05.heatingrates_binned.2006-2017.nc")