Skip to content

Commit

Permalink
updates for SEWG
Browse files Browse the repository at this point in the history
  • Loading branch information
wwieder committed Jan 29, 2025
1 parent c87b114 commit 00eedb1
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 108 deletions.
14 changes: 9 additions & 5 deletions config_clm_baseline_example.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#==============================
#config_cam_baseline_example.yaml
#config_clm_baseline_example.yaml

#This is the main CAM diagnostics config file
#for doing comparisons of a CAM run against
#another CAM run, or a CAM baseline simulation.
#This is the main CAM/CLM diagnostics config file
#for doing comparisons of a CAM or CLM run against
#another run, or baseline simulation.

#Currently, if one is on NCAR's Casper or
#Cheyenne machine, then only the diagnostic output
Expand Down Expand Up @@ -184,6 +184,7 @@ diag_cam_climo:
cam_ts_loc: /glade/derecho/scratch/${user}/ADF/${diag_cam_climo.cam_case_name}/ts

#TEM diagnostics
#TODO, this isn't needed for land, but may be a helpful way to think about looking at CLM h1 files
#---------------
#TEM history file number
#If missing or blank, ADF will default to h4
Expand Down Expand Up @@ -462,6 +463,8 @@ time_averaging_scripts:

#Name of regridding scripts being used.
#These scripts must be located in "scripts/regridding":
#TODO, this needs to be modified for a land model workflow
#This is not the regridding script wwieder made for land
regridding_scripts:
- regrid_and_vert_interp

Expand All @@ -471,7 +474,7 @@ analysis_scripts:
- amwg_table
#- aerosol_gas_tables

#List of plotting scripts being used.
#List of plotting scripts being used.
#These scripts must be located in "scripts/plotting":
plotting_scripts:
- global_unstructured_latlon_map
Expand All @@ -490,6 +493,7 @@ plotting_scripts:

#List of CAM variables that will be processesd:
#If CVDP is to be run PSL, TREFHT, TS and PRECT (or PRECC and PRECL) should be listed
#TODO, round this out with more variables for alpha land diags
diag_var_list:
- ELAI
- GPP
Expand Down
29 changes: 23 additions & 6 deletions lib/plot_uxarray_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,31 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"id": "55ceea85-e3e2-4e2e-a88c-03c1313acf31",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<xarray.UxDataArray 'GPP' (n_face: 48600)> Size: 389kB\n",
"array([ nan, nan, nan, ..., 1.27199839, 1.42239865,\n",
" 2.10174724])\n",
"Coordinates:\n",
" time int64 8B 1\n",
"Dimensions without coordinates: n_face\n",
"Attributes:\n",
" long_name: gross primary production\n",
" units: gC/m2/d\n",
" cell_methods: time: mean\n",
" landunit_mask: unknown\n",
"<xarray.UxDataArray (n_face: 48600)> Size: 194kB\n",
"array([ nan, nan, nan, ..., 4.2150470e-05,\n",
" 1.9083785e-05, 4.9214168e-06], dtype=float32)\n",
"Coordinates:\n",
" time int64 8B 1\n",
"Dimensions without coordinates: n_face\n",
"/glade/derecho/scratch/wwieder/testFig.png made\n"
]
}
Expand All @@ -119,8 +136,8 @@
"obsfld = b\n",
"diffld = c\n",
"pctld = d\n",
"area = ds0.area\n",
"landfrac = ds0.landfrac\n",
"area = ds0.area.isel(time=0)\n",
"landfrac = ds0.landfrac.isel(time=0)\n",
"wgt = area * landfrac / (area * landfrac).sum()\n",
"\n",
"plot_unstructured_map_and_save(wks, case_nickname, base_nickname,\n",
Expand All @@ -132,7 +149,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"id": "b288e743-1371-466c-8b03-7c3096ec9697",
"metadata": {},
"outputs": [
Expand All @@ -158,8 +175,8 @@
"obsfld = b.subset.bounding_box(lon_bounds, lat_bounds, element=element)\n",
"diffld = c.subset.bounding_box(lon_bounds, lat_bounds, element=element)\n",
"pctld = d.subset.bounding_box(lon_bounds, lat_bounds, element=element)\n",
"area = ds0.area.subset.bounding_box(lon_bounds, lat_bounds, element=element)\n",
"landfrac = ds0.landfrac.subset.bounding_box(lon_bounds, lat_bounds, element=element)\n",
"area = ds0.area.subset.bounding_box(lon_bounds, lat_bounds, element=element).isel(time=0)\n",
"landfrac = ds0.landfrac.subset.bounding_box(lon_bounds, lat_bounds, element=element).isel(time=0)\n",
"wgt = area * landfrac / (area * landfrac).sum()\n",
"\n",
"plot_unstructured_map_and_save(wks, case_nickname, base_nickname,\n",
Expand Down
224 changes: 131 additions & 93 deletions scripts/regridding/regrid_conservative.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions scripts/regridding/regrid_se_to_fv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np

def make_se_regridder(weight_file, s_data, d_data,
Method='coservative'
Method='coservative'
):
weights = xr.open_dataset(weight_file)
in_shape = weights.src_grid_dims.load().data
Expand All @@ -31,9 +31,9 @@ def make_se_regridder(weight_file, s_data, d_data,
"lon": ("lon", weights.xc_b.data.reshape(out_shape)[0, :]),
}
)
# Hard code masks for now
s_mask = xr.DataArray(s_data.data.reshape(in_shape[0],in_shape[1]), dims=("lat", "lon"))
dummy_in['mask']= s_mask
# Hard code masks for now, not sure this does anything?
s_mask = xr.DataArray(s_data.data.reshape(in_shape[0],in_shape[1]), dims=("lat", "lon"))
dummy_in['mask']= s_mask

d_mask = xr.DataArray(d_data.values, dims=("lat", "lon"))
dummy_out['mask']= d_mask
Expand Down

0 comments on commit 00eedb1

Please sign in to comment.