Skip to content

Commit

Permalink
Merge pull request #35 from kylejgillett/pr-34
Browse files Browse the repository at this point in the history
Merge changes from #34 with local changes | Stepwise CAPE and CIN plot.
  • Loading branch information
kylejgillett authored Dec 29, 2024
2 parents 693f70d + 2c69ecc commit a3ea0ff
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 71 deletions.
Binary file modified src/sounderpy/__pycache__/acars_data.cpython-312.pyc
Binary file not shown.
Binary file modified src/sounderpy/__pycache__/bufkit_data.cpython-312.pyc
Binary file not shown.
Binary file modified src/sounderpy/__pycache__/calc.cpython-312.pyc
Binary file not shown.
Binary file modified src/sounderpy/__pycache__/model_data.cpython-312.pyc
Binary file not shown.
Binary file modified src/sounderpy/__pycache__/obs_data.cpython-312.pyc
Binary file not shown.
Binary file modified src/sounderpy/__pycache__/plot.cpython-312.pyc
Binary file not shown.
Binary file modified src/sounderpy/__pycache__/sounderpy.cpython-312.pyc
Binary file not shown.
Binary file modified src/sounderpy/__pycache__/utils.cpython-312.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion src/sounderpy/acars_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Purpose of module:
House function for loading and parsing ACARS profiles and
House functions for loading and parsing ACARS profiles and
ACARS profile data. Functions here are explicitly called by
the user.
Expand Down
2 changes: 1 addition & 1 deletion src/sounderpy/bufkit_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Purpose of module:
House function for loading and parsing BUFKIT model forecast data.
House functions for loading and parsing BUFKIT model forecast data.
Functions here are referenced by sounderpy.py
Expand Down
15 changes: 14 additions & 1 deletion src/sounderpy/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ def locate_bounds(arr):
class sounding_params:


def __init__(self, clean_data, storm_motion='right_moving', modify_sfc=None):
def __init__(self, clean_data, storm_motion='right_moving', modify_sfc=None, include_all_parcels=False):
self.clean_data = clean_data
self.storm_motion = storm_motion
self.modify_sfc = modify_sfc
self.include_all_parcels = include_all_parcels


######################################################################################################
Expand Down Expand Up @@ -394,6 +395,18 @@ def interpolate(var,hgts,step):
thermo['dparcel_p'] = ma.masked
thermo['dparcel_T'] = ma.masked

#--- PARCEL PROFILES ---#
# ---------------------------------------------------------------
if self.include_all_parcels:
# Calculate parcels
parcels = [parcelx(prof, pres=p[i].m, tmpc=T[i].m, dwpc=Td[i].m) for i in range(len(p))]
thermo['cape_profile'] = np.array([pcl.bplus for pcl in parcels])
thermo['cin_profile'] = np.array([pcl.bminus for pcl in parcels])
thermo['3cape_profile'] = np.array([pcl.b3km for pcl in parcels])
# Interpolate
intrp['cape_profileINTRP'] = interpolate(thermo['cape_profile'], zINTRP, resolution)
intrp['cin_profileINTRP'] = interpolate(thermo['cin_profile'], zINTRP, resolution)
intrp['3cape_profileINTRP'] = interpolate(thermo['3cape_profile'], zINTRP, resolution)


# ENTRAINING CAPE NOW LOCATED BELOW KINEMATICS SECTION SO
Expand Down
5 changes: 5 additions & 0 deletions src/sounderpy/cm1_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def make_cm1_profile(filename, meta_data_dict):
3] # cm1 input has no surface hgt, use quadratic extrapolation to estimate sfc z
else:
elev = meta_data_dict['elev']

full_z[0] = elev

full_th[0] = float(sfc_th)
full_qv[0] = float(sfc_qv) / 1000. # convert to g/kg
full_u[0] = 1.75 * full_u[1] - full_u[2] + 0.25 * full_u[
Expand Down Expand Up @@ -123,6 +125,9 @@ def make_cm1_profile(filename, meta_data_dict):
check_sfc_hgt(full_z)
check_latlon(meta_data_dict)

# convert hgt values to include elevation
full_z[1:] = full_z[1:] + elev

#############################################
# CONSTRUCT CLEAN_DATA DICTIONARY
#############################################
Expand Down
214 changes: 151 additions & 63 deletions src/sounderpy/plot.py

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/sounderpy/sounderpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
THIS RELEASE
-------
Version: 3.0.6 | December 2024
Version: 3.0.7 | December 2024
DOCUMENTATION
Expand All @@ -50,7 +50,7 @@
citation_text = f"""
## ---------------------------------- SOUNDERPY ----------------------------------- ##
## Vertical Profile Data Retrieval and Analysis Tool For Python ##
## v3.0.6 | Dec 2024 | (C) Kyle J Gillett ##
## v3.0.7dev | Dec 2024 | (C) Kyle J Gillett ##
## Docs: https://kylejgillett.github.io/sounderpy/ ##
## --------------------- THANK YOU FOR USING THIS PACKAGE! ------------------------ ##
"""
Expand Down Expand Up @@ -206,7 +206,7 @@ def get_bufkit_data(model, station, fcst_hour, run_year=None, run_month=None, ru
#########################################################################
def build_sounding(clean_data, style='full', color_blind=False, dark_mode=False, storm_motion='right_moving',
special_parcels=None, show_radar=True, radar_time='sounding', map_zoom=2, modify_sfc=None,
save=False, filename='sounderpy_sounding'):
show_theta=False, save=False, filename='sounderpy_sounding'):

'''
Return a full sounding plot of SounderPy data, ``plt``
Expand All @@ -223,6 +223,7 @@ def build_sounding(clean_data, style='full', color_blind=False, dark_mode=False,
:type storm_motion: str or list of floats, optional
:param special_parcels: a nested list of special parcels from the ``ecape_parcels`` library. The nested list should be a list of two lists (`[[a, b], [c, d]]`) where the first list should include 'highlight parcels' and second list should include 'background parcels'. For more details, see the :ref:`parcels_logic` section.
:type special_parcels: nested `list` of two `lists`, optional
:param show_theta: bool, optional
:param save: whether to show the plot inline or save to a file. Default is ``False`` which displays the file inline.
:type save: bool, optional
:param filename: the filename by which a file should be saved to if ``save = True``. Default is `sounderpy_sounding`.
Expand All @@ -233,10 +234,11 @@ def build_sounding(clean_data, style='full', color_blind=False, dark_mode=False,

print(f'> SOUNDING PLOTTER FUNCTION\n ---------------------------------')

plt = __full_sounding(clean_data, color_blind, dark_mode, storm_motion, special_parcels, show_radar, radar_time, map_zoom, modify_sfc, show_theta)
if save:
__full_sounding(clean_data, color_blind, dark_mode, storm_motion, special_parcels, show_radar, radar_time, map_zoom, modify_sfc).savefig(filename, bbox_inches='tight')
plt.savefig(filename, bbox_inches='tight')
else:
__full_sounding(clean_data, color_blind, dark_mode, storm_motion, special_parcels, show_radar, radar_time, map_zoom, modify_sfc).show()
plt.show()



Expand Down

0 comments on commit a3ea0ff

Please sign in to comment.