Skip to content

Commit 29c685f

Browse files
authored
Merge pull request #102 from falconstryker/devel
fixed areo definition in dummy file script
2 parents 552d15c + 2aed367 commit 29c685f

2 files changed

Lines changed: 62 additions & 13 deletions

File tree

tests/create_ames_gcm_files.py

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,11 @@ def create_mgcm_atmos_average():
264264
areo_var = nc_file.createVariable('areo', 'f4', ('time', 'scalar_axis'))
265265
areo_var.long_name = 'areo'
266266
areo_var.units = 'degrees'
267-
areo_var[:] = np.linspace(722.2, 1076.5, 133)
268-
areo_var = areo_var[:, np.newaxis]
267+
areo_vals = np.linspace(722.2, 1076.5, 133)
268+
areo_data = np.zeros((133, 1)) # Create a 2D array with shape (133, 1)
269+
for i in range(133):
270+
areo_data[i, 0] = areo_vals[i]
271+
areo_var[:] = areo_data
269272

270273
cldcol_var = nc_file.createVariable('cldcol', 'f4', ('time', 'lat', 'lon'))
271274
cldcol_var.long_name = 'ice column'
@@ -376,8 +379,11 @@ def create_mgcm_atmos_daily():
376379
areo_var = nc_file.createVariable('areo', 'f4', ('time', 'scalar_axis'))
377380
areo_var.long_name = 'areo'
378381
areo_var.units = 'degrees'
379-
areo_var[:] = np.linspace(720.3, 1079.8, 2672)
380-
areo_var = areo_var[:, np.newaxis]
382+
areo_vals = np.linspace(720.3, 1079.8, 2672)
383+
areo_data = np.zeros((2672, 1)) # Create a 2D array with shape (133, 1)
384+
for i in range(2672):
385+
areo_data[i, 0] = areo_vals[i]
386+
areo_var[:] = areo_data
381387

382388
ps_var = nc_file.createVariable('ps', 'f4', ('time', 'lat', 'lon'))
383389
ps_var.long_name = 'surface pressure'
@@ -453,8 +459,11 @@ def create_mgcm_atmos_average_pstd():
453459
areo_var = nc_file.createVariable('areo', 'f4', ('time', 'scalar_axis'))
454460
areo_var.long_name = 'areo'
455461
areo_var.units = 'degrees'
456-
areo_var[:] = np.linspace(723.7, 1076.9, 133)
457-
areo_var = areo_var[:, np.newaxis]
462+
areo_vals = np.linspace(723.7, 1076.9, 133)
463+
areo_data = np.zeros((133, 1)) # Create a 2D array with shape (133, 1)
464+
for i in range(133):
465+
areo_data[i, 0] = areo_vals[i]
466+
areo_var[:] = areo_data
458467

459468
cldcol_var = nc_file.createVariable('cldcol', 'f4', ('time', 'lat', 'lon'))
460469
cldcol_var.long_name = 'ice column'
@@ -559,8 +568,27 @@ def create_mgcm_atmos_diurn_pstd():
559568
areo_var = nc_file.createVariable('areo', 'f4', ('time', 'time_of_day_24', 'scalar_axis'))
560569
areo_var.long_name = 'areo'
561570
areo_var.units = 'degrees'
562-
areo_var[:] = np.linspace(721.2, 1077.3, 133)
563-
areo_var = areo_var[:, np.newaxis]
571+
572+
# Create base values for areo dimension
573+
areo_base = np.linspace(721.2, 1077.3, 133)
574+
575+
# Create 3D array with shape (133, 24, 1)
576+
areo_data = np.zeros((133, 24, 1))
577+
578+
# Fill array with increasing values
579+
for t in range(133):
580+
# Base value for this areo
581+
base_val = areo_base[t]
582+
583+
# Daily oscillation (values increase slightly throughout the day)
584+
# Starting with a small offset and incrementing by a small amount
585+
for tod in range(24):
586+
# Small daily oscillation of ~0.4 degrees
587+
daily_increment = (tod / 24.0) * 0.4
588+
areo_data[t, tod, 0] = base_val - 0.2 + daily_increment
589+
590+
# Assign the data to the variable
591+
areo_var[:] = areo_data
564592

565593
ps_var = nc_file.createVariable('ps', 'f4', ('time', 'time_of_day_24', 'lat', 'lon'))
566594
ps_var.long_name = 'surface pressure'
@@ -641,8 +669,26 @@ def create_mgcm_atmos_diurn():
641669
areo_var = nc_file.createVariable('areo', 'f4', ('time', 'time_of_day_24', 'scalar_axis'))
642670
areo_var.long_name = 'areo'
643671
areo_var.units = 'degrees'
644-
areo_var[:] = np.linspace(721.2, 1077.3, 133)
645-
areo_var = areo_var[:, np.newaxis]
672+
# Create base values for areo dimension
673+
areo_base = np.linspace(721.2, 1077.3, 133)
674+
675+
# Create 3D array with shape (133, 24, 1)
676+
areo_data = np.zeros((133, 24, 1))
677+
678+
# Fill array with increasing values
679+
for t in range(133):
680+
# Base value for this areo
681+
base_val = areo_base[t]
682+
683+
# Daily oscillation (values increase slightly throughout the day)
684+
# Starting with a small offset and incrementing by a small amount
685+
for tod in range(24):
686+
# Small daily oscillation of ~0.4 degrees
687+
daily_increment = (tod / 24.0) * 0.4
688+
areo_data[t, tod, 0] = base_val - 0.2 + daily_increment
689+
690+
# Assign the data to the variable
691+
areo_var[:] = areo_data
646692

647693
ps_var = nc_file.createVariable('ps', 'f4', ('time', 'time_of_day_24', 'lat', 'lon'))
648694
ps_var.long_name = 'surface pressure'
@@ -725,8 +771,11 @@ def create_mgcm_atmos_average_pstd_c48():
725771
areo_var = nc_file.createVariable('areo', 'f4', ('time', 'scalar_axis'))
726772
areo_var.long_name = 'areo'
727773
areo_var.units = 'degrees'
728-
areo_var[:] = np.linspace(362.1, 716.6, 133)
729-
areo_var = areo_var[:, np.newaxis]
774+
areo_vals = np.linspace(362.1, 716.6, 133)
775+
areo_data = np.zeros((133, 1)) # Create a 2D array with shape (133, 1)
776+
for i in range(133):
777+
areo_data[i, 0] = areo_vals[i]
778+
areo_var[:] = areo_data
730779

731780
temp_var = nc_file.createVariable('temp', 'f4', ('time', 'pstd', 'lat', 'lon'))
732781
temp_var.long_name = 'temperature'

tests/test_marsfiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def test_split_file_by_areo(self):
322322
ls_max = np.max(areo_values) % 360
323323

324324
# Choose a range within the available values
325-
ls_range = [ls_min, ls_max]
325+
ls_range = [ls_min + 50 , ls_max - 50]
326326
finally:
327327
nc.close()
328328

0 commit comments

Comments
 (0)