From b0142343573aa910f89bd9e4ebcd28ac770acd87 Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 8 Oct 2024 10:18:15 -0600 Subject: [PATCH 1/2] docs --- docs/requirements.txt | 4 +++- ush/chgres_cold2fv3.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 7be32f526..aca438407 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,5 @@ sphinxcontrib-bibtex sphinx_rtd_theme -docutils==0.16 \ No newline at end of file +docutils==0.16 +numpy +netCDF4 diff --git a/ush/chgres_cold2fv3.py b/ush/chgres_cold2fv3.py index b8de4011f..1d90ab6e2 100755 --- a/ush/chgres_cold2fv3.py +++ b/ush/chgres_cold2fv3.py @@ -1,3 +1,6 @@ +""" +??? +""" import numpy as np from netCDF4 import Dataset import remap_dwinds @@ -6,6 +9,13 @@ import sys def nan_check(arr, name, check_id): + """ + NAN check? + + arr: ??? + name: ??? + check_id: ??? + """ nan_count = 0 nan_count = np.sum(np.isnan(arr)) print(f"coldstartwinds({check_id}) nan_count({name}): {nan_count}") From 3b2f120a94ee804103eb168081666207c81f2659 Mon Sep 17 00:00:00 2001 From: Ed Date: Thu, 10 Oct 2024 12:12:55 -0600 Subject: [PATCH 2/2] added docs --- ush/chgres_cold2fv3.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/ush/chgres_cold2fv3.py b/ush/chgres_cold2fv3.py index 1d90ab6e2..2dd7e10d1 100755 --- a/ush/chgres_cold2fv3.py +++ b/ush/chgres_cold2fv3.py @@ -1,5 +1,12 @@ -""" -??? +"""The purpose of this code is to convert a cold start file from +chgres_cube into a FV3 warm start (restart) file, enabling data +blending operators that require a warm start format. The code performs +essential transformations, including wind rotation and vertical +remapping of atmospheric scalars and winds, ensuring the cold start +data aligns with the FV3 model's restart format. Reason: The global 6 +h background from chgres_cube is a cold start and must be converted to +a warm start file to be able to blend with the 1 h EnKF restarts. + """ import numpy as np from netCDF4 import Dataset @@ -9,12 +16,28 @@ import sys def nan_check(arr, name, check_id): - """ - NAN check? + """NAN check function. + + This function checks a given array for NaN (Not a Number) values, + counts the total number of NaNs, and prints their indices if any + are found. It helps identify problematic data in the array that + may disrupt further processing. + + After all nan_checks are done, if there is at least one nan then + the code fails. I put a note right after the vertical remapping of + the wind that says "Perform a NaN check - sometimes will get NaNs + at this point". I don't think it should fail. I think it was more + of an issue in development and I kept the check there just to be + safe. + + Parameters: + arr: numpy array to be checked for NaN values. + name: string used to label the array in the output for identification. + check_id: integer or string identifier to differentiate between multiple checks in the output. + + Returns: + nan_count: integer representing the total number of NaN values found in the array. - arr: ??? - name: ??? - check_id: ??? """ nan_count = 0 nan_count = np.sum(np.isnan(arr))