Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os

from ndsl.dsl.typing import Float, Int
from ndsl import ndsl_log


_f32 = np.float32
Expand All @@ -13,14 +14,14 @@
NUMBER_OF_TRACERS = Int(23)

# Define number of tracers in UW
# NOTE depreciate this, change all references of NCNST to NUMBER_OF_TRACERS
# NOTE deprecate this, change all references of NCNST to NUMBER_OF_TRACERS
EXPERIMENT_TRACERS = {"bomex": 18, "armtwp_ice": 18, "gcm-fp": 23}
EXP_NAME = os.getenv("EXP_NAME", "")
if EXP_NAME == "":
raise ValueError("EXP_NAME env var is not set - experiment unknown.")
if EXP_NAME not in EXPERIMENT_TRACERS:
raise ValueError(f"Experiment {EXP_NAME} unknown - tracers can't be initialized.")
NCNST = _i32(EXPERIMENT_TRACERS[EXP_NAME])
ndsl_log.warning(f"Experiment unknown: choose one of {list(EXPERIMENT_TRACERS.keys())}. Falling back to default number of tracers ({NUMBER_OF_TRACERS}).")
NCNST = NUMBER_OF_TRACERS
else:
NCNST = _i32(EXPERIMENT_TRACERS[EXP_NAME])

# MAPL_UNDEF is set to 1E15 in the Fortran
# We keep it as is for now to match 11.5.2 GEOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __call__(self, state: GF2020State, convection_tracers: ConvectionTracers):
Args:
state (GF2020State): State of the overarching model - not all fields from the model are required
convection_tracers (ConvectionTracers): Collection of tracers from the rest of the model which
will be updated within convection. These may come from a variaty of sources, and need to be
will be updated within convection. These may come from a variety of sources, and need to be
collected into the expected ConvectionTracers data type before being passed down.
"""
# flag to stop convection scheme for single column models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def hydrostatic_air_density(
plume (Int)
"""
with computation(PARALLEL), interval(...):
# prefil with 0
# prefill with 0
air_density = 0.0

with computation(PARALLEL), interval(0, -1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def updraft_chemistry(
elif USE_TRACER_SCAVENGE == 2:
option_not_implemented = True

# formulation 3 - orignal GF conv_par
# formulation 3 - original GF conv_par
elif USE_TRACER_SCAVENGE == 3:
option_not_implemented = True

Expand Down Expand Up @@ -311,7 +311,7 @@ def downdraft_chemistry(

with computation(FORWARD), interval(0, 1):
if plume != cumulus_parameterization_constants.SHALLOW and error_code[0, 0][plume] == 0:
# fration of the total rain that was evaporated
# fraction of the total rain that was evaporated
evaporation_fraction: FloatFieldIJ = -total_normalized_integrated_evaporate_forced / (
1.0e-16 + total_normalized_integrated_condensate_forced[0, 0][plume]
)
Expand Down Expand Up @@ -858,7 +858,7 @@ def __call__(
chemistry_tracers_total_pw_updraft (Quantity)
chemistry_tracers_total_pw_downdraft (Quantity)
convection_tracers (ConvectionTracers): Collection of tracers from the rest of the model which
will be updated within convection. These may come from a variaty of sources, and need to be
will be updated within convection. These may come from a variety of sources, and need to be
collected into the expected ConvectionTracers data type before being passed down.
plume_dependent_constants (GF2020PlumeDependentConstants)

Expand Down Expand Up @@ -956,7 +956,7 @@ def __call__(
and self.cumulus_parameterization_config.ALP1 > 0.0
):
for tracer in range(self.config.NUMBER_OF_TRACERS):
# NOTE, this code is an extention of the vertical transport section for option
# NOTE, this code is an extension of the vertical transport section for option
# which executes when (USE_FLUX_FORM == 1 and ALP1 > 0.0)
self._tridiag(
m=cloud_top_level,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)
from pyMoist.convection.GF_2020.cumulus_parameterization.get_levels import (
cloud_top_checks,
find_detrainmet_start_level,
find_detrainment_start_level,
find_highest_moist_static_energy_level,
find_lcl,
find_maximum_updraft_origin_level,
Expand All @@ -64,7 +64,7 @@
)
from pyMoist.convection.GF_2020.cumulus_parameterization.precip import (
PrecipFactor,
cloud_dissapation,
cloud_dissipation,
get_precip_fluxes,
partition_liquid_ice,
rain_evaporation_below_cloud_base,
Expand Down Expand Up @@ -107,7 +107,7 @@

class GF2020CumulusParameterization(NDSLRuntime):
"""GF220 cumulus parameterization core. This component of GF2020 contains all of the science code related
to deep conveection, including (but not limited to):
to deep convection, including (but not limited to):
- updraft dynamics
- downdraft dynamics
- entrainment/detrainment
Expand All @@ -118,7 +118,7 @@ class GF2020CumulusParameterization(NDSLRuntime):

Most pieces are called directly, but more complicated parts are buried into their own subclass.

Not all parts/options are fully implemented, some have been implemetned without full testing.
Not all parts/options are fully implemented, some have been implemented without full testing.
ALL of these untested/unimplemented paths are locked behind an NotImplementedError, with an
appropriate message pointing to the configuration option that is causing the error.
"""
Expand Down Expand Up @@ -167,7 +167,6 @@ def __init__(
# initialize all the subclasses
self._setup = Setup(
stencil_factory=stencil_factory,
quantity_factory=quantity_factory,
config=config,
cumulus_parameterization_config=cumulus_parameterization_config,
)
Expand Down Expand Up @@ -206,8 +205,8 @@ def __init__(
compute_dims=[I_DIM, J_DIM, K_DIM],
)

self._find_detrainmet_start_level = stencil_factory.from_dims_halo(
func=find_detrainmet_start_level,
self._find_detrainment_start_level = stencil_factory.from_dims_halo(
func=find_detrainment_start_level,
compute_dims=[I_DIM, J_DIM, K_DIM],
)

Expand Down Expand Up @@ -263,7 +262,7 @@ def __init__(
},
)

self._downdraft_entraiment_profiles = stencil_factory.from_dims_halo(
self._downdraft_entrainment_profiles = stencil_factory.from_dims_halo(
func=downdraft_entrainment_profiles,
compute_dims=[I_DIM, J_DIM, K_DIM],
externals={"DOWNDRAFT": cumulus_parameterization_config.DOWNDRAFT},
Expand Down Expand Up @@ -400,14 +399,12 @@ def __init__(

self._updraft_initial_workfunctions = UpdraftInitialWorkfunctions(
stencil_factory=stencil_factory,
quantity_factory=quantity_factory,
config=config,
cumulus_parameterization_config=cumulus_parameterization_config,
)

self._updraft_cin = UpdraftCIN(
stencil_factory=stencil_factory,
quantity_factory=quantity_factory,
config=config,
cumulus_parameterization_config=cumulus_parameterization_config,
)
Expand Down Expand Up @@ -437,7 +434,6 @@ def __init__(

self._downdraft_windshear = DowndraftWindShear(
stencil_factory=stencil_factory,
quantity_factory=quantity_factory,
config=config,
cumulus_parameterization_config=cumulus_parameterization_config,
)
Expand Down Expand Up @@ -481,9 +477,8 @@ def __init__(
cumulus_parameterization_config=cumulus_parameterization_config,
)

self._update_workfunction_and_precipitaiton_ensemble = UpdateWorkfunctionAndPrecipitationEnsemble(
self._update_workfunction_and_precipitation_ensemble = UpdateWorkfunctionAndPrecipitationEnsemble(
stencil_factory=stencil_factory,
quantity_factory=quantity_factory,
config=config,
cumulus_parameterization_config=cumulus_parameterization_config,
)
Expand Down Expand Up @@ -521,8 +516,8 @@ def __init__(
compute_dims=[I_DIM, J_DIM, K_DIM],
)

self._cloud_dissapation = stencil_factory.from_dims_halo(
func=cloud_dissapation,
self._cloud_dissipation = stencil_factory.from_dims_halo(
func=cloud_dissipation,
compute_dims=[I_DIM, J_DIM, K_DIM],
externals={
"USE_CLOUD_DISSIPATION": cumulus_parameterization_config.USE_CLOUD_DISSIPATION,
Expand Down Expand Up @@ -582,7 +577,7 @@ def __call__(
This state is initialized in the GF2020Setup class. The overarching model state cannot be
passed to the GF2020CumulusParameterizationState because of incompatible K-axis orientation.
convection_tracers (ConvectionTracers): Collection of tracers from the rest of the model which
will be updated within convection. These may come from a variaty of sources, and need to be
will be updated within convection. These may come from a variety of sources, and need to be
collected into the expected ConvectionTracers data type before being passed down.
"""
if self.cumulus_parameterization_config.SHALLOW_MID_DEEP:
Expand Down Expand Up @@ -814,7 +809,7 @@ def __call__(
plume=self.plume_dependent_constants.PLUME_INDEX,
)

self._find_detrainmet_start_level(
self._find_detrainment_start_level(
geopotential_height=self.locals.geopotential_height_cloud_levels_forced,
topography_height_no_negative=state.input_output.topography_height_no_negative,
error_code=state.output.error_code,
Expand Down Expand Up @@ -884,8 +879,8 @@ def __call__(
ocean_fraction=state.input.ocean_fraction,
updraft_origin_level=state.output.updraft_origin_level,
p=state.input_output.p_forced,
environmenet_moist_static_energy=self.locals.environment_moist_static_energy_cloud_levels,
environmenet_moist_static_energy_forced=self.locals.environment_moist_static_energy_cloud_levels_forced,
environment_moist_static_energy=self.locals.environment_moist_static_energy_cloud_levels,
environment_moist_static_energy_forced=self.locals.environment_moist_static_energy_cloud_levels_forced,
t_perturbation=state.output.t_perturbation,
moist_static_energy_origin_level=self.locals.moist_static_energy_origin_level,
moist_static_energy_origin_level_forced=self.locals.moist_static_energy_origin_level_forced,
Expand Down Expand Up @@ -956,7 +951,7 @@ def __call__(
# NOTE deep ✅
# NOTE mid ✅
# NOTE shallow ✅
self._downdraft_entraiment_profiles(
self._downdraft_entrainment_profiles(
lateral_entrainment_rate=state.input.lateral_entrainment_rate,
entrainment_rate_downdraft=self.locals.entrainment_rate_downdraft,
detrainment_function_downdraft=self.locals.detrainment_function_downdraft,
Expand All @@ -977,8 +972,8 @@ def __call__(
ocean_fraction=state.input.ocean_fraction,
updraft_origin_level=state.output.updraft_origin_level,
p=state.input_output.p_forced,
environmenet_moist_static_energy=self.locals.environment_moist_static_energy_cloud_levels,
environmenet_moist_static_energy_forced=self.locals.environment_moist_static_energy_cloud_levels_forced,
environment_moist_static_energy=self.locals.environment_moist_static_energy_cloud_levels,
environment_moist_static_energy_forced=self.locals.environment_moist_static_energy_cloud_levels_forced,
t_perturbation=state.output.t_perturbation,
moist_static_energy_origin_level=self.locals.moist_static_energy_origin_level,
moist_static_energy_origin_level_forced=self.locals.moist_static_energy_origin_level_forced,
Expand Down Expand Up @@ -1516,12 +1511,12 @@ def __call__(
# NOTE shallow ✅
self._convection_trigger(
error_code=state.output.error_code,
convective_scale_velosity=state.input_output.convective_scale_velocity,
convective_scale_velocity=state.input_output.convective_scale_velocity,
cin_0=self.locals.cin_0,
plume=self.plume_dependent_constants.PLUME_INDEX,
)

# calculate downdraft air temperature for vertical velocitys
# calculate downdraft air temperature for vertical velocities
# NOTE test GF2020_CumulusParameterization_DowndraftTemperature_{plume}:
# NOTE deep ✅
# NOTE mid ✅
Expand Down Expand Up @@ -1573,8 +1568,8 @@ def __call__(

# determine downdraft strength in terms of windshear
# NOTE test GF2020_CumulusParameterization_DowndraftWindShear_{plume}:
# NOTE deep ❌ one field - three points, used to be
# NOTE mid ❌ one field 14 pointss, used to be ❌ one field, one point (0.17%), 4 ULP
# NOTE deep ✅
# NOTE mid
# NOTE shallow ✅
self._downdraft_windshear(
error_code=state.output.error_code,
Expand Down Expand Up @@ -1814,7 +1809,7 @@ def __call__(
# NOTE deep ✅
# NOTE mid ✅
# NOTE shallow ✅
self._update_workfunction_and_precipitaiton_ensemble(
self._update_workfunction_and_precipitation_ensemble(
error_code=state.output.error_code,
updraft_origin_level=state.output.updraft_origin_level,
updraft_lfc_level=state.output.updraft_lfc_level,
Expand Down Expand Up @@ -1995,7 +1990,7 @@ def __call__(
# NOTE deep ✅
# NOTE mid ✅
# NOTE shallow ✅
self._cloud_dissapation(
self._cloud_dissipation(
error_code=state.output.error_code,
updraft_lfc_level=state.output.updraft_lfc_level,
cloud_top_level=state.output.cloud_top_level,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ def get_downdraft_origin_level(
MINIMUM_DEPTH: Float,
plume: Int,
):
"""Determine the leve at which the downdraft begins.
"""Determine the level at which the downdraft begins.
For shallow plume, return 0 (downdraft is disabled). For mid and deep plume, perform full calculation.

This stencil contains an open-ended vertical solver with a nested vertical loop.
To implement this properly, the aforrementioned computation has been constructed on an interval(0, 1),
To implement this properly, the aforementioned computation has been constructed on an interval(0, 1),
and all K read/writes have been done with absolute indexes or relative offsets. The alternative is
to break this into a series of stencils and pass data between them using a much larger number of locals.

Following a decision made in a prior section of the GF2020 cumulus parameterizaiton core
Following a decision made in a prior section of the GF2020 cumulus parameterization core
see (get_convective_cloud_base_level), this has been implemented as one stencil using the inefficient
interval to preserve code readability and facilitate an easy future transition to another implementation,
once the required tool/feature has been implemented.
Expand Down Expand Up @@ -266,7 +266,7 @@ def downdraft_mass_flux(
_, _min_loc = column_min(p_internal, 0, downdraft_origin_level[0, 0][plume])
min_loc: IntFieldIJ = _min_loc

# this alpha constrains the location of the maximun ZU to be at "kb_adj" vertical level
# this alpha constrains the location of the maximum ZU to be at "kb_adj" vertical level
alpha: FloatFieldIJ = 1.0 + (beta - 1.0) * (
(min_loc + 1) / (downdraft_origin_level[0, 0][plume] + 2)
) / (1.0 - ((min_loc + 1) / (downdraft_origin_level[0, 0][plume] + 2)))
Expand Down Expand Up @@ -936,7 +936,7 @@ def downdraft_windshear(


with computation(FORWARD), interval(...):
if plume != 0 and error_code[0, 0][plume] == 0 and K > updraft_lfc_level[0, 0][plume] and K <= cloud_top_level[0, 0][plume]:
if plume != 0 and error_code[0, 0][plume] == 0 and K >= updraft_lfc_level[0, 0][plume] and K <= cloud_top_level[0, 0][plume]:
dp = p_forced - p_forced[0, 0, 1]
vws = (
vws
Expand Down Expand Up @@ -1024,7 +1024,7 @@ def update_epsilon_forced(
epsilon_forced: FloatFieldIJ_Plume,
plume: Int,
):
"""Tune precipitation effeciency (epsilon_computed) based on the scale dependence factor.
"""Tune precipitation efficiency (epsilon_computed) based on the scale dependence factor.

Args:
error_code (IntFieldIJ_Plume)
Expand All @@ -1046,7 +1046,7 @@ def update_epsilon_forced(


class DowndraftOriginLevel(NDSLRuntime):
"""Determine the leve at which the downdraft begins."""
"""Determine the level at which the downdraft begins."""

def __init__(
self,
Expand Down Expand Up @@ -1143,14 +1143,13 @@ def __call__(self, *args, **kwds):


class DowndraftWindShear(NDSLRuntime):
"""Calculate wint shear within the downdraft. Quantify the effect of wind shear within the downdraft
on precipitation into a "precip effeciency" field (epsilon_computed).
"""Calculate wind shear within the downdraft. Quantify the effect of wind shear within the downdraft
on precipitation into a "precip efficiency" field (epsilon_computed).
"""

def __init__(
self,
stencil_factory: StencilFactory,
quantity_factory: QuantityFactory,
config: GF2020Config,
cumulus_parameterization_config: GF2020CumulusParameterizationConfig,
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_interp(
t_new (Float)
vapor_forced (Float)
"""
# bunch of interal constants, not to be used outside of this function
# bunch of internal constants, not to be used outside of this function
rd = 287.06
rv = 461.52
rcpd = 1004.71
Expand Down
Loading
Loading