diff --git a/cost_function.py b/cost_function.py index 09320bb1352cd9047ca40b598fed73b36cabe4ce..91625384fe66b7ecf7e0a4909e3dee50c7df3319 100755 --- a/cost_function.py +++ b/cost_function.py @@ -48,23 +48,20 @@ def calculate_radii_rossby(list_eddies, e_overestim, handlers, array_d_init): # now that we have the location in the shapefiles, we need to # get the radius and the rossby number shapeRec = handlers[i_SHPC]["readers"]["extremum"].shapeRecord(location) - # rossby: - lat_in_deg = shapeRec.shape.points[0][1] - #[deg] - f = 2*Omega*math.sin(math.radians(lat_in_deg)) # [1/s] - - V_max = shapeRec.record[4] #[m/s] + lat_in_deg = shapeRec.shape.points[0][1] # in degrees + f = 2 * Omega * math.sin(math.radians(lat_in_deg)) # in s-1 + V_max = shapeRec.record[4] # in m/s R_Vmax = handlers[i_SHPC]["readers"]["max_speed_contour"]\ - .record(location)['r_eq_area'] * 1000 #[m] + .record(location)['r_eq_area'] * 1000 # in m if (V_max < 100): # calculate Ro and Delta_Ro - Ro = V_max / (f * R_Vmax) #[] + Ro = V_max / (f * R_Vmax) else: Ro = 0 days_modifier += 1 - radii += R_Vmax # [in m] + radii += R_Vmax # in m rossby += Ro return {"radii": radii, "rossby": rossby, "days_modifier": days_modifier} @@ -176,11 +173,10 @@ for n in g.vertices(): first_res = calculate_radii_rossby(segment[:num_of_days_to_avg], e_overestim, handlers, array_d_init) - # average and assign radii + # Average and assign the first radii: first_radii = first_res['radii'] / num_of_days_to_avg g.vp.first_av_rad[n] = first_radii - # grab the days modifier modifier = first_res['days_modifier'] if (num_of_days_to_avg - modifier > 0): @@ -188,7 +184,7 @@ for n in g.vertices(): first_rossby = first_res['rossby'] / (num_of_days_to_avg - modifier) g.vp.first_av_ros[n] = first_rossby - # Last 7 days calculation + # Last 7 days calculation: last_res = calculate_radii_rossby(segment[- num_of_days_to_avg:], e_overestim, handlers, array_d_init) @@ -196,7 +192,6 @@ for n in g.vertices(): last_radii = last_res['radii'] / num_of_days_to_avg g.vp.last_av_rad[n] = last_radii - # grab the days modifier modifier = last_res['days_modifier'] if (num_of_days_to_avg - modifier > 0):