Skip to content

Commit

Permalink
revert typos changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LuukBlom committed Jan 22, 2025
1 parent 7ae90b5 commit d4ffde0
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 88 deletions.
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# Ignore false-positives
waring = "waring"
fo = "fo"
pn = "pn"
22 changes: 11 additions & 11 deletions cht_cyclones/fit_holland_2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

# Definition to fit Holland 2010 wind field
def fit_wind_field_holland2010(
vmax, rmax, pc, vtreal, phit, on, phi_spiral, lat, dpdt, obs
vmax, rmax, pc, vtreal, phit, pn, phi_spiral, lat, dpdt, obs
):
# Discussion
# shouldnt we have a switch to only calibrate vt and phi_a for observed radii
# what about limits on these variables
# OK with xn calibration

# function to fit wind field based on Holland 2010
# function to fit wind field based pn Holland 2010
size_factor = 1
phi = np.arange(90, -270 - 10, -10) # radial angles (cartesian, degrees)
rmax = rmax * 1000 # convert from km to m
Expand Down Expand Up @@ -61,7 +61,7 @@ def fit_wind_field_holland2010(
vmax,
pc,
rmax,
on,
pn,
vtreal,
phit,
lat,
Expand All @@ -83,7 +83,7 @@ def fit_wind_field_holland2010(
vmax,
pc,
rmax,
on,
pn,
vtreal,
phit,
lat,
Expand All @@ -102,7 +102,7 @@ def fit_wind_field_holland2010(
vmax,
pc,
rmax,
on,
pn,
vtreal,
phit,
lat,
Expand Down Expand Up @@ -147,7 +147,7 @@ def fit_wind_field_holland2010(
vmax,
pc,
rmax,
on,
pn,
vtreal,
phit,
lat,
Expand All @@ -166,7 +166,7 @@ def fit_wind_field_holland2010(
vmax,
pc,
rmax,
on,
pn,
vtreal,
phit,
lat,
Expand Down Expand Up @@ -212,7 +212,7 @@ def fit_wind_field_holland2010(
vmax,
pc,
rmax,
on,
pn,
vtreal,
phit,
lat,
Expand All @@ -231,7 +231,7 @@ def fit_wind_field_holland2010(
vmax,
pc,
rmax,
on,
pn,
vtreal,
phit,
lat,
Expand Down Expand Up @@ -364,13 +364,13 @@ def compute_forward_speed_heading(t, x, y):

# definition to compute wind field
def compute_wind_field(
r, phi, vmax, pc, rmax, on, vtreal, phit, lat, dpdt, phi_spiral, xn, vt, phia
r, phi, vmax, pc, rmax, pn, vtreal, phit, lat, dpdt, phi_spiral, xn, vt, phia
):
# Discussion is asymmetry account for properly? I believe there should be a factor in front of ux/vy
vms = vmax - vt

# compute wind profile (vr and pr)
[vr, pr] = holland2010(r, vms, pc, on, rmax, dpdt, lat, vtreal, xn)
[vr, pr] = holland2010(r, vms, pc, pn, rmax, dpdt, lat, vtreal, xn)

wind_speed = np.zeros((phi.shape[0], r.shape[0]))
wind_to_direction_cart = np.zeros((phi.shape[0], r.shape[0]))
Expand Down
20 changes: 10 additions & 10 deletions cht_cyclones/perl/jtwc_advisory_to_cyc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ sub read_jtwc_file {
my $is_analysis = 0;
my ($nrec, $irad, $idist, $long_range, $extra, $iend) = (0) x 6;
my ($yr0,$mon0,$day0,$hr0,$min0,$sec0,$Dd,$Dh,$Dm,$Ds,$yr_now,$mon_now,$day_now,$hr_now,$min_now,$sec_now) = (0) x 16;
my ($temp, $rmw_orig, $rmw0, $rmw1, $rmw2, $i, $j, $ilat, $ilon, $sum, $num, @avg_dist, @rad_speed, @dist, @sorted_dist, @value, $yyyymm);
my ($temp, $rmw_orig, $rmw0, $rmw1, $rmw2, $i, $j, $ilat, $ilon, $sum, $num, @avg_dist, @rad_speed, @dist, @sorted_dist, @valu, $yyyymm);
# TC direction, speed parameters:
my ($inm, @start, @end, @tau, $dir, $km, @distnc, @reverse_s, @reverse_d, @r100, $ir100, $i3d, $k, $ind_sio, $previous);
my $nm2km = 1.852; # Conversion for nmi to km
Expand Down Expand Up @@ -938,8 +938,8 @@ sub read_jtwc_file {
# all data records. Therefore, as avg_dist varies in size, value will be zero-
# padded at the end (i.e., the right hand side). This may not work if avg_dist
# increases, then decreases.
@value = (0) x $maxlen;
@value[0..$#avg_dist] = @avg_dist;
@valu = (0) x $maxlen;
@valu[0..$#avg_dist] = @avg_dist;

# Print data to a temp file.
#if (($#avg_dist+1) < 1) {
Expand All @@ -949,7 +949,7 @@ sub read_jtwc_file {
#} else {
#print MYTEMP "$lat[$nrec] $lon[$nrec] $msw_kt[$nrec] $rmw[$nrec] $rmw0 $rmw1 $rmw2 @avg_dist\n";
#}
#print MYTEMP "$lat[$nrec] $lon[$nrec] $msw_kt[$nrec] $rmw[$nrec] $rmw0 $rmw1 $rmw2 @value\n";
#print MYTEMP "$lat[$nrec] $lon[$nrec] $msw_kt[$nrec] $rmw[$nrec] $rmw0 $rmw1 $rmw2 @valu\n";

# Now increment the index & clear local arrays.
#my @increment_line = split ' ', $_;
Expand Down Expand Up @@ -1283,16 +1283,16 @@ sub find_best_value {

my ($val, $failsafe, $v1, $v2, $v3) = @_;
my @candidates = ();
my ($value, $cand, $sum);
my ($valu, $cand, $sum);
my $div = 3; # Started with 4
my $small = $val/$div;
my $good = -9999;

foreach $value ($v1, $v2, $v3) {
if ($value > $val || $value < $small) {
$value = 0;
foreach $valu ($v1, $v2, $v3) {
if ($valu > $val || $valu < $small) {
$valu = 0;
} else {
push @candidates, ($value);
push @candidates, ($valu);
}
}

Expand All @@ -1305,7 +1305,7 @@ sub find_best_value {
$good = $candidates[0];
} else {
# Mean of candidate values.
foreach $value (@candidates) { $sum += $value; }
foreach $valu (@candidates) { $sum += $valu; }
#$good = $candidates[0];
$good = $sum/$cand;
}
Expand Down
30 changes: 15 additions & 15 deletions cht_cyclones/perl/nhc_advisory_to_cyc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
# is zero (i.e., for the 1st advisory's output). (RSL)
# 21 Jul 2006 Fixed bug in 3rd date algorithm in sub. process_data. (RSL)
# 12 Sep 2006 Defined $MeanRMW in sub. DUMP; modified sub. print_data to set any
# zero RMW value to the mean; changed ambient air pressure, $on, in sub.
# zero RMW value to the mean; changed ambient air pressure, $pn, in sub.
# process_data to 1013.25 (std. atmosphere). (RSL)
# 28 Jul 2011 Added sub. wind_pressure_relationship to better estimate minimum
# central pressure given wind speed (Dvorak technique); replaced the def.
Expand Down Expand Up @@ -118,7 +118,7 @@
# added '$storm_id' and '$warning_number' parambers to sub. process_data;
# upgraded sub. get_radius to add parameters & code to load the output 3-D
# wind radii array; updated the call to sub. print_track_file to include
# the environmental pressure ($on) and to use the new 3-D wind radii
# the environmental pressure ($pn) and to use the new 3-D wind radii
# array (@r100_65_50_35_3D). (RSL)
# 18 May 2012 Added '$warn_id' for the storm warning ID (based on the input file
# name without the extension). (RSL)
Expand Down Expand Up @@ -160,7 +160,7 @@
# $EBT_MISS (missing value code), @rad_outer_iso (radius of the
# outermost closed isobar) for the extended best track output option;
# added @pres_outer_iso to store the background pressure in an array for
# the best track output option; replaced $on with @pres_outer_iso in the
# the best track output option; replaced $pn with @pres_outer_iso in the
# call to sub. write_ext_best_track. (RSL)
# 07 Feb 2013 Added new array @storm_id_strs to store the storm ID string & pass
# to sub. write_ext_best_track for the extended best track option.
Expand Down Expand Up @@ -302,7 +302,7 @@
if ($for_rad[$i] == 0) { $for_rad[$i] = $MeanRMW; }
# Convert RMW from km to nmi for non-PCTides output.
$for_rad[$i] /= $nm2km;
$pres_outer_iso[$i] = $on;
$pres_outer_iso[$i] = $pn;
$storm_id_strs[$i] = $storm_id;
if ($i == 0) {
$eye_diam[$i] = $eye_diameter;
Expand All @@ -320,7 +320,7 @@
# Check whether the @pres_outer_iso array has any values.
if (!@pres_outer_iso) {
# It has none, so load it with background pressure values.
@pres_outer_iso = ($on) x scalar(@for_rad); # Load this array
@pres_outer_iso = ($pn) x scalar(@for_rad); # Load this array
}

# Check the input best track file flag.
Expand Down Expand Up @@ -633,7 +633,7 @@ sub process_data {
# Constants for output file header:
$rho = 1.15; # Air density, kg/m^3
$e = exp(1); # Base of natural log
$on = 1013.25; # Ambient air pressure (far from edge of storm), mb - Originally 1005
$pn = 1013.25; # Ambient air pressure (far from edge of storm), mb - Originally 1005
$mb2npm2 = 100; # Conversion factor, mb to N/m^2
$kn2mps = 0.514444; # Conversion factor, knots to m/s
$BMin = 1; # Minimum valid Holland "B" value
Expand Down Expand Up @@ -830,9 +830,9 @@ sub process_data {
if ($cp < $CP_MIN) {
warn " WARNING: Central Pressure \($cp\) < Minimum \($CP_MIN mb\); resetting to Minimum.\n";
$cp = $CP_MIN;
} elsif ($cp > $on) {
warn " WARNING: Central Pressure \($cp\) > Ambient \($on mb\); resetting to Ambient.\n";
$cp = $on;
} elsif ($cp > $pn) {
warn " WARNING: Central Pressure \($cp\) > Ambient \($pn mb\); resetting to Ambient.\n";
$cp = $pn;
}
}

Expand Down Expand Up @@ -1441,7 +1441,7 @@ sub process_data {
$for_cp[$nforecast] = $cp;
} else {
# Invalid, so use ambient.
$for_cp[$nforecast] = $on;
$for_cp[$nforecast] = $pn;
}
} else {
# Past the 1st forecast, so check the previous value.
Expand All @@ -1450,7 +1450,7 @@ sub process_data {
$for_cp[$nforecast] = $for_cp[$nforecast-1];
} else {
# Invalid, so use ambient.
$for_cp[$nforecast] = $on;
$for_cp[$nforecast] = $pn;
}
}
}
Expand All @@ -1460,7 +1460,7 @@ sub process_data {
# Calculate Holland B parameter based on current observations. Warn the user
# if B is invalid, and reset the value to either the min or max valid value.
# Calculation is performed only if not appending to the output flag.
if ($appendflag != 1 && $winds > 0 && $cp != $on) { $B = ($rho * $e * (($winds * $kn2mps)**2)) / (abs($on - $cp) * $mb2npm2); }
if ($appendflag != 1 && $winds > 0 && $cp != $pn) { $B = ($rho * $e * (($winds * $kn2mps)**2)) / (abs($pn - $cp) * $mb2npm2); }
if ($B > $BMax) {
warn " NOTICE: Holland B parameter exceeds $BMax; resetting to $BMax.\n";
$B = $BMax;
Expand Down Expand Up @@ -1900,9 +1900,9 @@ sub DUMP {
if ($for_cp[$i] < $CP_MIN) {
warn " WARNING: Forecast Central Pressure \($for_cp[$i]\) < Minimum \($CP_MIN mb\); resetting to Minimum.\n";
$for_cp[$i] = $CP_MIN;
} elsif ($for_cp[$i] > $on) {
warn " WARNING: Forecast Central Pressure \($for_cp[$i]\) > Ambient \($on mb\); resetting to Ambient.\n";
$for_cp[$i] = $on;
} elsif ($for_cp[$i] > $pn) {
warn " WARNING: Forecast Central Pressure \($for_cp[$i]\) > Ambient \($pn mb\); resetting to Ambient.\n";
$for_cp[$i] = $pn;
}

##print "DDate: $ddate CP: $cp WInds: $winds For_Wind: $for_winds[$i] Ratio: $ratio: For_CP: $for_cp[$i].\n";
Expand Down
6 changes: 3 additions & 3 deletions cht_cyclones/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def estimate_missing_values(self, config):
# estimate this: vmax is in m/s
vmax = wpr_holland2008(
pc=self.gdf.pc[it],
on=config["background_pressure"],
pn=config["background_pressure"],
phi=coords_it.y,
dpcdt=self.gdf.dpcdt[it],
vt=np.sqrt(self.gdf.vtx[it] ** 2 + self.gdf.vty[it] ** 2),
Expand All @@ -347,7 +347,7 @@ def estimate_missing_values(self, config):
if self.unit_intensity == "knots":
pc = wpr_holland2008(
vmax=self.gdf.vmax[it] * knots_to_ms,
on=self.background_pressure,
pn=self.background_pressure,
phi=coords_it.y,
dpcdt=self.gdf.dpcdt[it],
vt=np.sqrt(self.gdf.vtx[it] ** 2 + self.gdf.vty[it] ** 2),
Expand All @@ -356,7 +356,7 @@ def estimate_missing_values(self, config):
else:
pc = wpr_holland2008(
vmax=self.gdf.vmax[it],
on=config["background_pressure"],
pn=config["background_pressure"],
phi=coords_it.y,
dpcdt=self.gdf.dpcdt[it],
vt=np.sqrt(self.gdf.vtx[it] ** 2 + self.gdf.vty[it] ** 2),
Expand Down
Loading

0 comments on commit d4ffde0

Please sign in to comment.