@@ -75,12 +75,16 @@ def extract_inversion_sets_by_reach(self,sword_data_continent,swordreachids):
7575
7676 sword_data_reach = self .pull_sword_attributes_for_reach (sword_data_continent ,k )
7777
78+ # Check and see if there are reaches up and down for the reach
7879 if sword_data_reach ['n_rch_up' ]== 1 and sword_data_reach ['n_rch_down' ]== 1 :
79- InversionSet = self .find_set_for_reach (sword_data_reach ,swordreachids ,sword_data_continent )
80- InversionSet ['ReachList' ],InversionSet ['numReaches' ]= self .get_reach_list (InversionSet )
81- InversionSets [reach ['reach_id' ]]= InversionSet
82-
8380
81+ # Check and be sure the above isn't an error, sometimes SWORD v16 has it so that the number of reaches up variable says 1, but the reach id is 0
82+ if len (sword_data_reach ['rch_id_up' ])== 1 and len (sword_data_reach ['rch_id_dn' ]) == 1 :
83+ if sword_data_reach ['rch_id_up' ][0 ] != 0 and sword_data_reach ['rch_id_dn' ][0 ] != 0 :
84+ InversionSet = self .find_set_for_reach (sword_data_reach ,swordreachids ,sword_data_continent )
85+ InversionSet ['ReachList' ],InversionSet ['numReaches' ]= self .get_reach_list (InversionSet )
86+ InversionSets [reach ['reach_id' ]]= InversionSet
87+
8488 return InversionSets
8589
8690 def pull_sword_attributes_for_reach (self ,sword_data_continent ,k ):
@@ -188,6 +192,14 @@ def CheckReaches(self,sword_data_reach,sword_data_reach_adjacent,direction,verbo
188192
189193 AdjacentReachIsRiver = str (sword_data_reach_adjacent ['reach_id' ])[- 1 ]== '1'
190194
195+ AdjacentReachHasValidUp = True
196+ if len (sword_data_reach_adjacent ['rch_id_up' ]) > 0 :
197+ AdjacentReachHasValidUp = sword_data_reach_adjacent ['rch_id_up' ][0 ] != 0
198+
199+ AdjacentReachHasValidDown = True
200+ if len (sword_data_reach_adjacent ['rch_id_dn' ]) > 0 :
201+ AdjacentReachHasValidDown = sword_data_reach_adjacent ['rch_id_dn' ][0 ] != 0
202+
191203 OrbitsAreIdentical = False
192204 if sword_data_reach ['swot_obs' ]== sword_data_reach_adjacent ['swot_obs' ]:
193205 OrbitsAreIdentical = list (sword_data_reach ['swot_orbits' ])== list (sword_data_reach_adjacent ['swot_orbits' ])
@@ -209,6 +221,10 @@ def CheckReaches(self,sword_data_reach,sword_data_reach_adjacent,direction,verbo
209221 ReachesMakeAValidSet = False
210222 if not AdjacentReachIsRiver :
211223 ReachesMakeAValidSet = False
224+ if not AdjacentReachHasValidDown :
225+ ReachesMakeAValidSet = False
226+ if not AdjacentReachHasValidUp :
227+ ReachesMakeAValidSet = False
212228
213229 if verbose :
214230 print ('reach:' ,sword_data_reach )
0 commit comments