7474 "metadata": {},
7575 "outputs": [],
7676 "source": [
77- "formulae = Formulae(\n",
77+ "FORMULAE = Formulae(\n",
7878 " isotope_equilibrium_fractionation_factors='HoritaAndWesolowski1994',\n",
7979 " isotope_meteoric_water_line='Dansgaard1964',\n",
8080 " isotope_ratio_evolution='MerlivatAndJouzel1979',\n",
8181 ")\n",
82- "BACKEND = CPU(formulae , override_jit_flags={'parallel': False})\n",
83- "const = formulae .constants\n",
84- "trivia = formulae .trivia\n",
82+ "BACKEND = CPU(FORMULAE , override_jit_flags={'parallel': False})\n",
83+ "CONST = FORMULAE .constants\n",
84+ "TRIVIA = FORMULAE .trivia\n",
8585 "\n",
8686 "FIG4_CAPTION_PARAMS = {\n",
87- " 'T_init': const .T0 + 25 * si.K,\n",
87+ " 'T_init': CONST .T0 + 25 * si.K,\n",
8888 " 'P_init': 1000 * si.mbar,\n",
89- " 'RH_init': 80 * const .PER_CENT,\n",
89+ " 'RH_init': 80 * CONST .PER_CENT,\n",
9090 " # note: R0 in the caption, but negative, hence delta\n",
91- " 'delta_2H_init': -74.7 * const .PER_MILLE,\n",
91+ " 'delta_2H_init': -74.7 * CONST .PER_MILLE,\n",
9292 " # the \"K\" parameter\n",
9393 " 'isotope_exchange_factor': 1.,\n",
9494 " # the \"N_L\" parameter, note: mixing ratio in the caption, but per-volume units, hence density; assuming 1 kg/m3\n",
9595 " 'autoconversion_mixrat_threshold': 1 * si.g / si.m**3 / (1 * si.kg / si.m**3)\n",
9696 "}\n",
9797 "\n",
9898 "ARBITRARY_PARAMS = {\n",
99- " 'delta_18O_init': formulae .isotope_meteoric_water_line.d18O_of_d2H(\n",
99+ " 'delta_18O_init': FORMULAE .isotope_meteoric_water_line.d18O_of_d2H(\n",
100100 " delta_2H=FIG4_CAPTION_PARAMS['delta_2H_init']\n",
101101 " ),\n",
102102 " 'N_SUPER_DROPLETS': 1,\n",
106106 "}\n",
107107 "ARBITRARY_PARAMS['PARCEL_CTOR_ARGS'] = {\n",
108108 " 'p0': FIG4_CAPTION_PARAMS['P_init'],\n",
109- " 'initial_water_vapour_mixing_ratio': const .eps / ( # TODO #1207: use a physics formula \n",
109+ " 'initial_water_vapour_mixing_ratio': CONST .eps / ( # TODO #1207: use a physics formula \n",
110110 " FIG4_CAPTION_PARAMS['P_init']\n",
111111 " / FIG4_CAPTION_PARAMS['RH_init']\n",
112- " / formulae .saturation_vapour_pressure.pvs_water(FIG4_CAPTION_PARAMS['T_init'])\n",
112+ " / FORMULAE .saturation_vapour_pressure.pvs_water(FIG4_CAPTION_PARAMS['T_init'])\n",
113113 " - 1\n",
114114 " ),\n",
115115 " 'T0': FIG4_CAPTION_PARAMS['T_init'],\n",
162162 " alpha_old = {}\n",
163163 " dRv__dt = {}\n",
164164 " for isotope in self.isotopes:\n",
165- " alpha_fun = getattr(formulae.isotope_equilibrium_fractionation_factors, f'alpha_l_{isotope}')\n",
165+ " alpha_fun = getattr(self.particulator. formulae.isotope_equilibrium_fractionation_factors, f'alpha_l_{isotope}')\n",
166166 " alpha_old[isotope] = alpha_fun(self[\"T\"][0])\n",
167167 " alpha_new = alpha_fun(self._tmp[\"T\"][0])\n",
168168 " \n",
169- " dRv__dt[isotope] = self[f'Rv_{isotope}'][0] * self.formulae.isotope_ratio_evolution.d_Rv_over_Rv(\n",
169+ " dRv__dt[isotope] = self[f'Rv_{isotope}'][0] * self.particulator. formulae.isotope_ratio_evolution.d_Rv_over_Rv(\n",
170170 " alpha=alpha_old[isotope],\n",
171171 " d_alpha=(alpha_new - alpha_old[isotope]) / self.dt,\n",
172172 " n_vapour=self['water_vapour_mixing_ratio'][0],\n",
231231 " builder.add_dynamic(dynamics.Condensation())\n",
232232 "\n",
233233 " for isotope in isotopes:\n",
234- " builder.particulator.environment[f\"Rv_{isotope}\"][:] = formulae.trivia .isotopic_delta_2_ratio(\n",
234+ " builder.particulator.environment[f\"Rv_{isotope}\"][:] = TRIVIA .isotopic_delta_2_ratio(\n",
235235 " delta=(FIG4_CAPTION_PARAMS if isotope == \"2H\" else ARBITRARY_PARAMS)[f'delta_{isotope}_init'],\n",
236- " reference_ratio=getattr(const , f\"VSMOW_R_{isotope}\")\n",
236+ " reference_ratio=getattr(CONST , f\"VSMOW_R_{isotope}\")\n",
237237 " )\n",
238238 " \n",
239239 " super().__init__(particulator = builder.build(\n",
1222312223 "PLOT_KEY = 'd'\n",
1222412224 "print(output[PLOT_KEY][0]['Δz'])\n",
1222512225 "\n",
12226- "temp_C = output[PLOT_KEY][0][\"T\"] - const .T0\n",
12226+ "temp_C = output[PLOT_KEY][0][\"T\"] - CONST .T0\n",
1222712227 "alt_km = in_unit(output[PLOT_KEY][0][\"z\"], si.km) \n",
1222812228 "\n",
1222912229 "fig, axs = pyplot.subplots(2, 4, squeeze=False, sharey=True, figsize=(11.5, 11.5), tight_layout=True)\n",
1223812238 "axs[0,0].yaxis.set_major_locator(ticker.MultipleLocator(5))\n",
1223912239 "\n",
1224012240 "axs[0,0].plot(\n",
12241- " output[PLOT_KEY][0]['RH'] / const .PER_CENT,\n",
12241+ " output[PLOT_KEY][0]['RH'] / CONST .PER_CENT,\n",
1224212242 " temp_C,\n",
1224312243 " color='purple',\n",
1224412244 " label='RH',\n",
1227712277 " (ARBITRARY_PARAMS['N_ITERATIONS']-1) // ARBITRARY_PARAMS['N_PLOT_PROFILES']\n",
1227812278 " ):\n",
1227912279 " deltas = {\n",
12280- " iso: formulae.trivia .isotopic_ratio_2_delta(\n",
12280+ " iso: TRIVIA .isotopic_ratio_2_delta(\n",
1228112281 " ratio=output[PLOT_KEY][iteration][f'{ratio}_{iso}'][level_indices['CB']:],\n",
12282- " reference_ratio=getattr(const , f\"VSMOW_R_{iso}\")\n",
12282+ " reference_ratio=getattr(CONST , f\"VSMOW_R_{iso}\")\n",
1228312283 " ) for iso in ISOTOPES\n",
1228412284 " }\n",
1228512285 " \n",
@@ -12292,15 +12292,15 @@
1229212292 " for ax, iso, color in ((axs[plot_row, 1], '2H', 'green'), (axs[plot_row, 2], \"18O\", 'brown')):\n",
1229312293 " ax.set_title(title)\n",
1229412294 " ax.plot(\n",
12295- " in_unit(deltas[iso], const .PER_MILLE),\n",
12295+ " in_unit(deltas[iso], CONST .PER_MILLE),\n",
1229612296 " temp_C[level_indices['CB']:],\n",
1229712297 " color=color,\n",
1229812298 " **iter_kwargs\n",
1229912299 " )\n",
1230012300 " axs[plot_row, 3].plot(\n",
1230112301 " in_unit(\n",
12302- " formulae .isotope_meteoric_water_line.excess_d(delta_2H=deltas[\"2H\"], delta_18O=deltas[\"18O\"]),\n",
12303- " const .PER_MILLE\n",
12302+ " FORMULAE .isotope_meteoric_water_line.excess_d(delta_2H=deltas[\"2H\"], delta_18O=deltas[\"18O\"]),\n",
12303+ " CONST .PER_MILLE\n",
1230412304 " ),\n",
1230512305 " temp_C[level_indices['CB']:],\n",
1230612306 " color='black',\n",
@@ -14719,19 +14719,19 @@
1471914719 " colors = {'vapour': 'red', 'rain': 'blue'}\n",
1472014720 " linewidth = 1 + .5 * PARAMS_KEYS.index(key)\n",
1472114721 " line_v = axs.plot(\n",
14722- " in_unit(formulae.trivia .isotopic_ratio_2_delta(\n",
14722+ " in_unit(TRIVIA .isotopic_ratio_2_delta(\n",
1472314723 " ratio=data[key]['CT'][\"Rv_2H\"][1:],\n",
14724- " reference_ratio=const .VSMOW_R_2H\n",
14725- " ), const .PER_MILLE),\n",
14724+ " reference_ratio=CONST .VSMOW_R_2H\n",
14725+ " ), CONST .PER_MILLE),\n",
1472614726 " label=f\"vapour at the cloud top ({in_unit(levels['CT'], si.km)} km)\",\n",
1472714727 " color=colors['vapour'],\n",
1472814728 " linewidth=linewidth\n",
1472914729 " )\n",
1473014730 "\n",
14731- " rain_data = in_unit(formulae.trivia .isotopic_ratio_2_delta(\n",
14731+ " rain_data = in_unit(TRIVIA .isotopic_ratio_2_delta(\n",
1473214732 " ratio=data[key]['CB'][\"Rr_2H\"][1:],\n",
14733- " reference_ratio=const .VSMOW_R_2H\n",
14734- " ), const .PER_MILLE)\n",
14733+ " reference_ratio=CONST .VSMOW_R_2H\n",
14734+ " ), CONST .PER_MILLE)\n",
1473514735 " line_r = twinx.plot(\n",
1473614736 " rain_data,\n",
1473714737 " label=f\"rain at the cloud base ({in_unit(levels['CB'], si.km)} km)\",\n",
0 commit comments