Skip to content

Commit

Permalink
version 1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloceano committed Oct 21, 2024
1 parent 523fcfa commit 8f37007
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 28 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to this project will be documented in this file.

## [1.0.9] - 2024-10-21

### Fixed

- **LEC Fixed Framework**: Fixed a bug where the vertical levels output file was not saving the correct pressure levels as columns. Now, the output correctly reflects the pressure levels.

- **LEC Moving Framework**: Resolved a bug that prevented the framework from correctly handling maximum vorticity for the Northern Hemisphere track files. The framework now properly processes maximum vorticity values for the Northern Hemisphere.

- **Plot Periods**: Enhanced the functionality to check if the track is for the Northern Hemisphere. If so, the vorticity values are multiplied by `-1` to ensure correct behavior in the CycloPhaser program.

### Added

- **Tools.py**: Added a preprocessing stage to remove the new dimensions (`expver` and `number`) introduced in recent ERA5 datasets, ensuring compatibility with previous workflows.

## [1.0.8] - 2024-09-05

### Added
Expand Down
9 changes: 4 additions & 5 deletions inputs/box_limits
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
min_lon;-60
max_lon;-30
min_lat;-42.5
max_lat;-17.5

min_lon;-101.5
max_lon;-76.5
min_lat;16.6
max_lat;31.5
19 changes: 9 additions & 10 deletions inputs/namelist
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
;standard_name;Variable;Units
Air Temperature;air_temperature;TMP_2_ISBL;K
Geopotential Height;geopotential_height;HGT_2_ISBL;m
Omega Velocity;omega;V_VEL_2_ISBL;Pa/s
Eastward Wind Component;eastward_wind;U_GRD_2_ISBL;m/s
Northward Wind Component;northward_wind;V_GRD_2_ISBL;m/s
Longitude;;lon_2
Latitude;;lat_2
Time;;initial_time0_hours
Vertical Level;;lv_ISBL3

Air Temperature;air_temperature;t;K
Geopotential;geopotential;z;m**2/s**2
Omega Velocity;omega;w;Pa/s
Eastward Wind Component;eastward_wind;u;m/s
Northward Wind Component;northward_wind;v;m/s
Longitude;;longitude
Latitude;;latitude
Time;;valid_time
Vertical Level;;pressure_level
10 changes: 10 additions & 0 deletions inputs/namelist_ERA5-copernicus-new
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
;standard_name;Variable;Units
Air Temperature;air_temperature;t;K
Geopotential;geopotential;z;m**2/s**2
Omega Velocity;omega;w;Pa/s
Eastward Wind Component;eastward_wind;u;m/s
Northward Wind Component;northward_wind;v;m/s
Longitude;;longitude
Latitude;;latitude
Time;;valid_time
Vertical Level;;pressure_level
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read_requirements():

setup(
name='LorenzCycleToolkit',
version='1.0.8',
version='1.0.9',
packages=find_packages(),
include_package_data=True,
install_requires=read_requirements(),
Expand Down
46 changes: 38 additions & 8 deletions src/frameworks/lec_fixed_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: daniloceano <danilo.oceano@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/19 17:32:59 by daniloceano #+# #+# #
# Updated: 2024/07/18 00:20:44 by daniloceano ### ########.fr #
# Updated: 2024/10/21 12:22:32 by daniloceano ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -82,7 +82,7 @@ def lec_fixed(
variable_list_df.loc["Vertical Level"]["Variable"],
)

pres = data[VerticalCoordIndexer] * data[VerticalCoordIndexer].metpy.units
PressureData = data[VerticalCoordIndexer] * data[VerticalCoordIndexer].metpy.units
app_logger.info(
f"Bounding box: min_lon={min_lon}, max_lon={max_lon}, min_lat={min_lat}, max_lat={max_lat}"
)
Expand Down Expand Up @@ -110,7 +110,7 @@ def lec_fixed(
"Ck_4",
"Ck_5",
]:
columns = [TimeName] + [float(i) / 100 for i in pres.values]
columns = [TimeName] + [float(i) for i in PressureData.values]
output_path = Path(results_subdirectory_vertical_levels, f"{term}_{VerticalCoordIndexer}.csv")
pd.DataFrame(columns=columns).to_csv(output_path, index=None)

Expand Down Expand Up @@ -229,8 +229,38 @@ def lec_fixed(

app_logger.info("Generating plots..")
figures_directory = os.path.join(results_subdirectory, "Figures")
plot_timeseries(results_file, figures_directory, app_logger)
plot_box_limits(box_limits_file, figures_directory, app_logger)
boxplot_terms(results_file, results_subdirectory, figures_directory, app_logger)
plot_hovmoller(results_file, figures_directory, app_logger)
plot_lorenzcycletoolkit(results_file, figures_directory, app_logger=app_logger)

# Plot time series
try:
plot_timeseries(results_file, figures_directory, app_logger)
app_logger.info("Successfully generated time series plot.")
except Exception as e:
app_logger.error(f"Error occurred while generating time series plot: {e}")

# Plot box limits
try:
plot_box_limits(box_limits_file, figures_directory, app_logger)
app_logger.info("Successfully generated box limits plot.")
except Exception as e:
app_logger.error(f"Error occurred while generating box limits plot: {e}")

# Plot boxplot terms
try:
boxplot_terms(results_file, results_subdirectory, figures_directory, app_logger)
app_logger.info("Successfully generated boxplot terms.")
except Exception as e:
app_logger.error(f"Error occurred while generating boxplot terms: {e}")

# Plot Hovmöller diagram
try:
plot_hovmoller(results_file, figures_directory, app_logger)
app_logger.info("Successfully generated Hovmöller plot.")
except Exception as e:
app_logger.error(f"Error occurred while generating Hovmöller plot: {e}")

# Plot Lorenz cycle toolkit
try:
plot_lorenzcycletoolkit(results_file, figures_directory, app_logger=app_logger)
app_logger.info("Successfully generated Lorenz cycle plot.")
except Exception as e:
app_logger.error(f"Error occurred while generating Lorenz cycle plot: {e}")
12 changes: 10 additions & 2 deletions src/frameworks/lec_moving_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: daniloceano <danilo.oceano@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/19 17:32:55 by daniloceano #+# #+# #
# Updated: 2024/07/18 00:36:10 by daniloceano ### ########.fr #
# Updated: 2024/10/21 13:56:21 by daniloceano ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -335,10 +335,18 @@ def get_position(
LonIndexer: slice(limits["min_lon"], limits["max_lon"]),
}
)
min_max_zeta_unformatted = izeta_850_slice.min()

# Get mininum vorticity if in the southern hemisphere
if limits["min_lat"] < 0:
min_max_zeta_unformatted = izeta_850_slice.min()
# Get maximum vorticity if in the northern hemisphere
else:
min_max_zeta_unformatted = izeta_850_slice.max()

# Get minimum vorticity if in the southern hemisphere
if limits["min_lat"] < 0:
min_max_zeta = float(np.nanmin(min_max_zeta_unformatted))
# Get maximum vorticity if in the northern hemisphere
else:
min_max_zeta = float(np.nanmax(min_max_zeta_unformatted))

Expand Down
5 changes: 4 additions & 1 deletion src/plots/plot_periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: daniloceano <danilo.oceano@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/01/02 23:38:49 by daniloceano #+# #+# #
# Updated: 2024/07/14 10:10:32 by daniloceano ### ########.fr #
# Updated: 2024/10/21 13:41:38 by daniloceano ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -47,6 +47,9 @@ def plot_periods(
os.makedirs(periods_figure_directory, exist_ok=True)
vorticity_data = out_track["min_max_zeta_850"].to_list()

if out_track['central_lat'].mean() > 0:
vorticity_data = [x * -1 for x in vorticity_data]

options_high_res = {
"use_filter": "auto",
"replace_endpoints_with_lowpass": 24,
Expand Down
8 changes: 7 additions & 1 deletion src/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: daniloceano <danilo.oceano@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/19 17:33:03 by daniloceano #+# #+# #
# Updated: 2024/07/18 09:38:56 by daniloceano ### ########.fr #
# Updated: 2024/10/21 13:15:43 by daniloceano ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -357,6 +357,12 @@ def process_data(
data = data.assign_coords({"rlons": np.deg2rad(data[LonIndexer])})
app_logger.debug("Ok.")

# Drop unnecessary dimensions
if 'expver' in data.coords:
data = data.drop('expver')
if 'number' in data.coords:
data = data.drop('number')

levels_Pa = (
data[LevelIndexer] * units(str(data[LevelIndexer].units))
).metpy.convert_units("Pa")
Expand Down

0 comments on commit 8f37007

Please sign in to comment.