Skip to content

Commit

Permalink
update files to generate OBS from IOP to include time units
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Bogenschutz committed Feb 7, 2025
1 parent 76a980d commit afd1747
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions IOP_diagnostics/OBS_to_Model_format/ARM97_to_DPxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

# Define input and output file paths
input_file = "/global/cfs/cdirs/e3sm/inputdata/atm/cam/scam/iop/ARM97_iopfile_4scam.nc"
output_file = "/pscratch/sd/b/bogensch/dp_screamxx_conv/obs_data/OBS_ARM97.dpxx.nc"
time_offset = 5.0
output_file = "/pscratch/sd/b/bogensch/dp_screamxx_conv/obs_data/OBS_ARM97_full.dpxx.nc"
time_offset = 0.0

# Ensure the directory for the output file exists
output_dir = os.path.dirname(output_file)
Expand All @@ -23,7 +23,7 @@

# 1. Transfer and adjust the "time" variable
time_data = ds_in["tsec"].values
time_data = time_data/86400.
time_data = (time_data-time_data[0])/86400.
ds_out["time"] = xr.DataArray(time_data - time_offset, dims=["time"])

p_data = ds_in["lev"].values/100.
Expand Down Expand Up @@ -66,6 +66,9 @@
# Copy attributes from the input dataset to the output dataset
ds_out.attrs = ds_in.attrs

# Add the units attribute
ds_out["time"].attrs["units"] = "days since 1997-06-18 23:29:45"

# Save the new dataset to a NetCDF file
ds_out.to_netcdf(output_file)

Expand Down
7 changes: 5 additions & 2 deletions IOP_diagnostics/OBS_to_Model_format/DYNAMO_to_DPxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Define input and output file paths
input_file = "/global/cfs/cdirs/e3sm/inputdata/atm/cam/scam/iop/DYNAMO_amie_iopfile_4scam.nc"
output_file = "/pscratch/sd/b/bogensch/dp_screamxx_conv/obs_data/OBS_DYNAMO_amie.dpxx.nc"
time_offset = 13.0
time_offset = 0.0

# Ensure the directory for the output file exists
output_dir = os.path.dirname(output_file)
Expand All @@ -23,7 +23,7 @@

# 1. Transfer and adjust the "time" variable
time_data = ds_in["tsec"].values
time_data = time_data/86400.
time_data = (time_data-time_data[0])/86400.
ds_out["time"] = xr.DataArray(time_data - time_offset, dims=["time"])

p_data = ds_in["lev"].values/100.
Expand Down Expand Up @@ -70,6 +70,9 @@
# Copy attributes from the input dataset to the output dataset
ds_out.attrs = ds_in.attrs

# Add the units attribute
ds_out["time"].attrs["units"] = "days since 2011-10-02 00:00:00"

# Save the new dataset to a NetCDF file
ds_out.to_netcdf(output_file)

Expand Down
5 changes: 4 additions & 1 deletion IOP_diagnostics/OBS_to_Model_format/GATEIII_to_DPxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# 1. Transfer and adjust the "time" variable
time_data = ds_in["tsec"].values
time_data = time_data/86400.
time_data = (time_data-time_data[0])/86400.
ds_out["time"] = xr.DataArray(time_data - time_offset, dims=["time"])

p_data = ds_in["lev"].values/100.
Expand Down Expand Up @@ -65,6 +65,9 @@
# Copy attributes from the input dataset to the output dataset
ds_out.attrs = ds_in.attrs

# Add the units attribute
ds_out["time"].attrs["units"] = "days since 1974-08-30 00:00:00"

# Save the new dataset to a NetCDF file
ds_out.to_netcdf(output_file)

Expand Down

0 comments on commit afd1747

Please sign in to comment.