Skip to content
Snippets Groups Projects
Commit ecf6347e authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Do not store all records from `max_speed_contour`

Do not store in memory all the records from shapefile
`max_speed_contour`.
parent b02c7e98
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ def comp_ishape(d_init, ishape_last, days_1950, eddy_index):
#######################
def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, extremum,
max_rcd, ishape_last):
max_speed, ishape_last):
radii = 0 #[m]
rossby = 0 #[1/s]
......@@ -67,7 +67,7 @@ def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, extremum,
f = 2*2*math.pi/(24*3600)*math.sin(math.radians(lat_in_deg)) # [1/s]
V_max = shapeRec.record[4] #[m/s]
R_Vmax = max_rcd[year][location]['r_eq_area'] * 1000 #[m]
R_Vmax = max_speed[year].record(location)['r_eq_area'] * 1000 #[m]
if (V_max < 100):
......@@ -150,20 +150,6 @@ num_of_days_to_avg = 7
# we iterate on the years because the segments are non sequential in time
for yr in range(1993, 2019):
print(f'Current year: {yr}')
print('Loading shapefiles...')
max_rcd = {}
max_rcd[yr] = max_speed[yr].records()
# check if we are reaching the last two years or the last year
if (yr <= 2017):
max_rcd[yr+1] = max_speed[yr + 1].records()
if (yr <= 2016):
max_rcd[yr+2] = max_speed[yr + 2].records()
print("Finished reading shapefiles.")
# iterate on the vertices
for n in g.vertices():
......@@ -229,7 +215,7 @@ for yr in range(1993, 2019):
# First 7 days calculation
first_res = calculate_radii_and_rossby(0, num_of_days_to_avg,
1, segment, e_overestim,
extremum, max_rcd,
extremum, max_speed,
ishape_last)
# average and assign radii
......@@ -253,7 +239,7 @@ for yr in range(1993, 2019):
-1,
segment, e_overestim,
extremum,
max_rcd, ishape_last)
max_speed, ishape_last)
# Average and assign the last radii
last_radii = last_res['radii'] / num_of_days_to_avg
......@@ -276,7 +262,7 @@ for yr in range(1993, 2019):
else:
res = calculate_radii_and_rossby(0, num_of_days, 1, segment,
e_overestim,
extremum, max_rcd, ishape_last)
extremum, max_speed, ishape_last)
# grab the days modifier
modifier = res['days_modifier']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment