@@ -27,14 +27,20 @@ def __init__(self, yaml_fn=None):
2727
2828 with open (yaml_fn , "r" ) as fn :
2929 bc_yaml = load (fn )
30- self .date = bc_yaml ["bctides" ]["date" ]
31- if "earth_tidals" in bc_yaml ["bctides" ].keys ():
32- self .earth_tidals = bc_yaml ["bctides" ]["earth_tidals" ]
30+
31+ main_id = "bctides"
32+ self .date = bc_yaml [main_id ]["date" ]
33+ if "earth_tidals" in bc_yaml [main_id ].keys ():
34+ self .earth_tidals = bc_yaml [main_id ]["earth_tidals" ]
3335 else :
3436 self .earth_tidals = None
35- self .boundary_tidals = bc_yaml ["bctides" ]["bounary_forcing_tidals" ]
36- self .open_boundaries = bc_yaml ["bctides" ]["open_boundaries" ]
37- self .hgrid = bc_yaml ["bctides" ]["hgrid_input_file" ]
37+ if "bounary_forcing_tidals" in bc_yaml [main_id ].keys ():
38+ self .boundary_tidals = bc_yaml [main_id ]["bounary_forcing_tidals" ]
39+ else :
40+ self .boundary_tidals = None
41+
42+ self .open_boundaries = bc_yaml [main_id ]["open_boundaries" ]
43+ self .hgrid = bc_yaml [main_id ]["hgrid_input_file" ]
3844
3945 self .elev_type = {
4046 "elev.th" : 1 ,
@@ -99,22 +105,22 @@ def write_bctides(self, bctides_file):
99105
100106 ##out earth tidal potential if any
101107 if self .earth_tidals :
102- num_tidal = len (self .earth_tidals ["tidal_constitutes " ])
108+ num_tidal = len (self .earth_tidals ["tidal_constituents " ])
103109 cutoff_depth = self .earth_tidals ["tidal_cutoff_depth" ]
104110 outf .write (str (num_tidal ) + " " + str (cutoff_depth ) + "\n " )
105111 for i in range (num_tidal ):
106112 outf .write (
107- self .earth_tidals ["tidal_constitutes " ][i ]["tidal_constitute " ]
113+ self .earth_tidals ["tidal_constituents " ][i ]["name " ]
108114 )
109115 outf .write ("\n " )
110- amp = self .earth_tidals ["tidal_constitutes " ][i ]["amplitude" ]
111- node_factor = self .earth_tidals ["tidal_constitutes " ][i ][
116+ amp = self .earth_tidals ["tidal_constituents " ][i ]["amplitude" ]
117+ node_factor = self .earth_tidals ["tidal_constituents " ][i ][
112118 "node_factor"
113119 ]
114- freq = self .earth_tidals ["tidal_constitutes " ][i ][
120+ freq = self .earth_tidals ["tidal_constituents " ][i ][
115121 "angular_frequency"
116122 ]
117- eqa = self .earth_tidals ["tidal_constitutes " ][i ][
123+ eqa = self .earth_tidals ["tidal_constituents " ][i ][
118124 "earth_equilibrium_argument"
119125 ]
120126 outf .write (
@@ -134,20 +140,20 @@ def write_bctides(self, bctides_file):
134140
135141 ## out boundary forcing tidal
136142 if self .boundary_tidals :
137- num_tidal = len (self .boundary_tidals ["tidal_constitutes " ])
143+ num_tidal = len (self .boundary_tidals ["tidal_constituents " ])
138144 outf .write (str (num_tidal ) + "\n " )
139145 for i in range (num_tidal ):
140146 outf .write (
141- self .boundary_tidals ["tidal_constitutes " ][i ]["tidal_constitute " ]
147+ self .boundary_tidals ["tidal_constituents " ][i ]["name " ]
142148 )
143149 outf .write ("\n " )
144- freq = self .boundary_tidals ["tidal_constitutes " ][i ][
150+ freq = self .boundary_tidals ["tidal_constituents " ][i ][
145151 "angular_frequency"
146152 ]
147- node_factor = self .boundary_tidals ["tidal_constitutes " ][i ][
153+ node_factor = self .boundary_tidals ["tidal_constituents " ][i ][
148154 "node_factor"
149155 ]
150- eqa = self .boundary_tidals ["tidal_constitutes " ][i ][
156+ eqa = self .boundary_tidals ["tidal_constituents " ][i ][
151157 "earth_equilibrium_argument"
152158 ]
153159 outf .write (str (freq ) + " " + str (node_factor ) + " " + str (eqa ))
@@ -198,7 +204,7 @@ def write_bctides(self, bctides_file):
198204 elev_boundary = None
199205 if "elevation_boundary" in self .open_boundaries [i ].keys ():
200206 elev_boundary = self .open_boundaries [i ]["elevation_boundary" ]
201- elev_source = elev_boundary ["boundary " ]
207+ elev_source = elev_boundary ["type " ]
202208 elev_key = elev_source
203209 if isinstance (elev_source , numbers .Number ):
204210 elev_key = "constant"
@@ -216,7 +222,7 @@ def write_bctides(self, bctides_file):
216222 vel_boundary = None
217223 if "velocity_boundary" in self .open_boundaries [i ].keys ():
218224 vel_boundary = self .open_boundaries [i ]["velocity_boundary" ]
219- vel_source = vel_boundary ["boundary " ]
225+ vel_source = vel_boundary ["type " ]
220226 vel_key = vel_source
221227
222228 if isinstance (vel_source , numbers .Number ):
@@ -239,7 +245,7 @@ def write_bctides(self, bctides_file):
239245 temp_boundary = None
240246 if "temperature_boundary" in self .open_boundaries [i ].keys ():
241247 temp_boundary = self .open_boundaries [i ]["temperature_boundary" ]
242- temp_source = temp_boundary ["boundary " ]
248+ temp_source = temp_boundary ["type " ]
243249 temp_key = temp_source
244250 if isinstance (temp_source , numbers .Number ):
245251 temp_key = "constant"
@@ -254,7 +260,7 @@ def write_bctides(self, bctides_file):
254260 salt_boundary = None
255261 if "salinity_boundary" in self .open_boundaries [i ].keys ():
256262 salt_boundary = self .open_boundaries [i ]["salinity_boundary" ]
257- salt_source = salt_boundary ["boundary " ]
263+ salt_source = salt_boundary ["type " ]
258264 salt_key = salt_source
259265 if isinstance (salt_source , numbers .Number ):
260266 salt_key = "constant"
@@ -275,9 +281,7 @@ def write_bctides(self, bctides_file):
275281 self .open_boundaries [i ]["tracers" ]
276282 )
277283 for j in range (boundary_tracer_mod_num ):
278- tracer_boundary = self .open_boundaries [i ]["tracers" ][j ][
279- "boundary"
280- ]
284+ tracer_boundary = self .open_boundaries [i ]["tracers" ][j ]["type" ]
281285 tracer_mod = self .open_boundaries [i ]["tracers" ][j ]["tracer" ]
282286 tracer_boundary_key = tracer_boundary
283287 if isinstance (tracer_boundary , numbers .Number ):
@@ -321,12 +325,12 @@ def write_bctides(self, bctides_file):
321325 outf .write (str (elev_source ))
322326 elif (elev_id == 3 ) or (elev_id == 5 ):
323327 ## tidal forcing
324- num_tidal_constitutes = elev_boundary ["tidal_constitutes " ]
325- for tidal_constitute in elev_boundary ["tidal_constitutes " ]:
326- outf .write (tidal_constitute [ "tidal_constitute " ] + "\n " )
328+ num_tidal_constituents = elev_boundary ["tidal_constituents " ]
329+ for tidal_constituent in elev_boundary ["tidal_constituents " ]:
330+ outf .write (tidal_constituent [ "name " ] + "\n " )
327331 for kk in range (num_nodes ):
328- amp = tidal_constitute [ "tidal_amplitude " ]
329- phase = tidal_constitute [ "tidal_phase " ]
332+ amp = tidal_constituent [ "amplitude " ]
333+ phase = tidal_constituent [ "phase " ]
330334 node_id = node_id_lst [kk ]
331335 x = hgrid .nodes [node_id , 0 ]
332336 y = hgrid .nodes [node_id , 1 ]
@@ -360,17 +364,17 @@ def write_bctides(self, bctides_file):
360364 outf .write (str (vel_source ))
361365 elif (vel_id == 3 ) or (vel_id == 5 ):
362366 ## tidal forcing
363- for tidal_constitute in vel_boundary ["tidal_constitutes " ]:
364- outf .write (tidal_constitute [ "tidal_constitute " ] + "\n " )
367+ for tidal_constituent in vel_boundary ["tidal_constituents " ]:
368+ outf .write (tidal_constituent [ "name " ] + "\n " )
365369 for kk in range (num_nodes ):
366- u_amp = tidal_constitute ["u_amplitude" ]
367- u_phase = tidal_constitute ["u_phase" ]
368- v_amp = tidal_constitute ["v_amplitude" ]
369- v_phase = tidal_constitute ["v_phase" ]
370+ u_amp = tidal_constituent ["u_amplitude" ]
371+ u_phase = tidal_constituent ["u_phase" ]
372+ v_amp = tidal_constituent ["v_amplitude" ]
373+ v_phase = tidal_constituent ["v_phase" ]
370374 node_id = node_id_lst [kk ]
371375 x = hgrid .nodes [node_id , 0 ]
372376 y = hgrid .nodes [node_id , 1 ]
373-
377+
374378 if isinstance (u_amp , numbers .Number ):
375379 u_amp_val = u_amp
376380 elif isinstance (
@@ -451,15 +455,15 @@ def write_bctides(self, bctides_file):
451455
452456 ## temperature bc parameters
453457 if temp_id == 2 :
454- temp_bc = temp_boundary ["boundary " ]
458+ temp_bc = temp_boundary ["type " ]
455459 outf .write (str (temp_bc ) + "\n " )
456460 if temp_id > 0 :
457461 nudge = temp_boundary ["nudge" ]
458462 outf .write (str (nudge ) + "\n " )
459463
460464 ## salt bc parameters
461465 if salt_id == 2 :
462- salt_bc = salt_boundary ["boundary " ]
466+ salt_bc = salt_boundary ["type " ]
463467 outf .write (str (salt_bc ) + "\n " )
464468 if salt_id > 0 :
465469 nudge = salt_boundary ["nudge" ]
@@ -471,16 +475,16 @@ def write_bctides(self, bctides_file):
471475 tracer = self .open_boundaries [i ]["tracers" ][tracer_index ]
472476 tracer_bc_type = tracer_boundary_types [ii ]
473477 if tracer_bc_type == 2 :
474- tracer_bc_const = tracer ["boundary " ]
478+ tracer_bc_const = tracer ["type " ]
475479 if isinstance (tracer_bc_const , list ):
476480 for val in tracer_bc_const :
477481 outf .write (str (val ) + " " )
478482 else :
479483 outf .write (str (tracer_bc_const ))
480484 outf .write ("\n " )
481485 if tracer_bc_type > 0 :
482- nudge = tracer ["nudge " ]
483- outf .write (str (nudge ) + "\n " )
486+ relax = tracer ["relax " ]
487+ outf .write (str (relax ) + "\n " )
484488
485489
486490if __name__ == "__main__" :
@@ -497,37 +501,37 @@ def write_bctides(self, bctides_file):
497501# hgrid_input_file: G:\schism\bctides\hgrid.gr3
498502# earth_tidals:
499503# tidal_cutoff_depth: 40
500- # tidal_constitutes :
501- # - tidal_constitute : Sa
504+ # tidal_constituents :
505+ # - name : Sa
502506# amplitude: 0.05
503507# node_factor: 1.0
504508# angular_frequency: 0.0027
505509# earth_equilibrium_argument: 0.01
506- # - tidal_constitute : O1
510+ # - name : O1
507511# amplitude: 0.2
508512# node_factor: 1.1
509513# angular_frequency: 4.001
510514# earth_equilibrium_argument: 0.0
511- # - tidal_constitute : M2
515+ # - name : M2
512516# amplitude: 0.5
513517# node_factor: 0.99
514518# angular_frequency: 1.9323
515519# earth_equilibrium_argument: 0.0
516520# bounary_forcing_tidals:
517- # tidal_constitutes :
518- # - tidal_constitute : Z0
521+ # tidal_constituents :
522+ # - name : Z0
519523# angular_frequency: 0.0
520524# node_factor: 1
521525# earth_equilibrium_argument: 0
522- # - tidal_constitute : O1
526+ # - name : O1
523527# angular_frequency: 0.675977E-04
524528# node_factor: 1.11945
525529# earth_equilibrium_argument: 7.47302
526- # - tidal_constitute : K1
530+ # - name : K1
527531# angular_frequency: 0.729212E-04
528532# node_factor: 1.07391
529533# earth_equilibrium_argument: 206.78674
530- # - tidal_constitute : M2
534+ # - name : M2
531535# angular_frequency: 0.140519E-04
532536# node_factor: 0.97907
533537# earth_equilibrium_argument: 217.04138
@@ -536,38 +540,38 @@ def write_bctides(self, bctides_file):
536540# name: ocean
537541# elevation_boundary:
538542# boundary: tidal
539- # tidal_constitutes :
540- # - tidal_constitute : Z0
541- # tidal_amplitude : 1.0
542- # tidal_phase : 0.0
543- # - tidal_constitute : O1
544- # tidal_amplitude : 0.226
545- # tidal_phase : 206
546- # - tidal_constitute : K1
547- # tidal_amplitude : 0.369
548- # tidal_phase : 220
549- # - tidal_constitute : M2
550- # tidal_amplitude : 0.578
551- # tidal_phase : 190
543+ # tidal_constituents :
544+ # - name : Z0
545+ # amplitude : 1.0
546+ # phase : 0.0
547+ # - name : O1
548+ # amplitude : 0.226
549+ # phase : 206
550+ # - name : K1
551+ # amplitude : 0.369
552+ # phase : 220
553+ # - name : M2
554+ # amplitude : 0.578
555+ # phase : 190
552556# velocity_boundary:
553557# boundary: tidal
554- # tidal_constitutes :
555- # - tidal_constitute : Z0
558+ # tidal_constituents :
559+ # - name : Z0
556560# u_amplitude: 0.20
557561# u_phase: 0.0
558562# v_amplitude: 0.10
559563# v_phase: 0.0
560- # - tidal_constitute : O1
564+ # - name : O1
561565# u_amplitude: 0.0226
562566# u_phase: 206
563567# v_amplitude: 0.0226
564568# v_phase: 206
565- # - tidal_constitute : K1
569+ # - name : K1
566570# u_amplitude: 0.0369
567571# u_phase: 220
568572# v_amplitude: 0.0226
569573# v_phase: 206
570- # - tidal_constitute : M2
574+ # - name : M2
571575# u_amplitude: 0.0578
572576# u_phase: 190
573577# v_amplitude: 0.0226
@@ -727,38 +731,38 @@ def write_bctides(self, bctides_file):
727731# name: north bay
728732# elevation_boundary:
729733# boundary: tidal elev2D.th.nc
730- # tidal_constitutes :
731- # - tidal_constitute : Z0
732- # tidal_amplitude : 1.0
733- # tidal_phase : 0.0
734- # - tidal_constitute : O1
735- # tidal_amplitude : 0.226
736- # tidal_phase : 206
737- # - tidal_constitute : K1
738- # tidal_amplitude : 0.369
739- # tidal_phase : 220
740- # - tidal_constitute : M2
741- # tidal_amplitude : 0.578
742- # tidal_phase : 190
734+ # tidal_constituents :
735+ # - name : Z0
736+ # amplitude : 1.0
737+ # phase : 0.0
738+ # - name : O1
739+ # amplitude : 0.226
740+ # phase : 206
741+ # - name : K1
742+ # amplitude : 0.369
743+ # phase : 220
744+ # - name : M2
745+ # amplitude : 0.578
746+ # phase : 190
743747# velocity_boundary:
744748# boundary: tidal uv3D.th.nc
745- # tidal_constitutes :
746- # - tidal_constitute : Z0
749+ # tidal_constituents :
750+ # - name : Z0
747751# u_amplitude: 0.20
748752# u_phase: 0.0
749753# v_amplitude: 0.10
750754# v_phase: 0.0
751- # - tidal_constitute : O1
755+ # - name : O1
752756# u_amplitude: 0.0226
753757# u_phase: 206
754758# v_amplitude: 0.0226
755759# v_phase: 206
756- # - tidal_constitute : K1
760+ # - name : K1
757761# u_amplitude: 0.0369
758762# u_phase: 220
759763# v_amplitude: 0.0226
760764# v_phase: 206
761- # - tidal_constitute : M2
765+ # - name : M2
762766# u_amplitude: 0.0578
763767# u_phase: 190
764768# v_amplitude: 0.0226
0 commit comments