Skip to content

Commit

Permalink
make compatible to sunpy6.0/numpy2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jgieseler committed Jul 22, 2024
1 parent b804ef0 commit 9ca1eed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions solarmach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def __init__(self, date, body_list, vsw_list=[], reference_long=None, reference_

try:
pos_E = get_horizons_coord(399, self.date, None) # (lon, lat, radius) in (deg, deg, AU)
except ValueError:
except (ValueError, RuntimeError):
print('')
print('!!! No ephemeris found for Earth for date {self.date} - there probably is a problem with JPL HORIZONS.')
if coord_sys=='Carrington':
Expand Down Expand Up @@ -315,7 +315,7 @@ def __init__(self, date, body_list, vsw_list=[], reference_long=None, reference_
if self.reference_lat is not None:
lat_sep = pos.lat.value - self.reference_lat
latsep_list.append(lat_sep)
except ValueError:
except (ValueError, RuntimeError):
print('')
print('!!! No ephemeris for target "' + str(body) + '" for date ' + str(self.date))
body_list.remove(body)
Expand Down Expand Up @@ -344,7 +344,7 @@ def __init__(self, date, body_list, vsw_list=[], reference_long=None, reference_
self.coord_table['Longitudinal separation between body and reference_long'] = longsep_list
self.coord_table[
"Longitudinal separation between body's magnetic footpoint and reference_long"] = footp_longsep_list
self.pfss_table.loc[len(self.pfss_table.index)] = ["Reference Point", self.reference_long, self.reference_lat, 1, np.NaN]
self.pfss_table.loc[len(self.pfss_table.index)] = ["Reference Point", self.reference_long, self.reference_lat, 1, np.nan]
if self.reference_lat is not None:
self.coord_table['Latitudinal separation between body and reference_lat'] = latsep_list
self.pfss_table.loc[self.pfss_table["Spacecraft/Body"]=="Reference Point", f"{coord_sys} latitude (°)"] = self.reference_lat
Expand Down Expand Up @@ -1248,7 +1248,7 @@ def plot_pfss(self,

else:
# Set the reach of the flux tube to nan, since it doesn't even reach up to the source surface
self.reference_long_min, self.reference_long_max = np.NaN, np.NaN
self.reference_long_min, self.reference_long_max = np.nan, np.nan

ref_arr = plt.arrow(np.deg2rad(self.reference_long), 1, 0, arrow_dist, head_width=0.1, head_length=0.5, edgecolor='black',
facecolor='black', lw=1., zorder=7, overhang=0.5)
Expand Down Expand Up @@ -1457,7 +1457,7 @@ def legend_arrow(width, height, **_):
if self.reference_long:
photospheric_footpoints.append(self.reference_long)
fieldline_polarities.append(ref_objects[0].polarity)
self.pfss_table["Reference flux tube lon range"] = [np.NaN if i<len(self.body_dict) else (self.reference_long_min, self.reference_long_max) for i in range(len(self.body_dict)+1)]
self.pfss_table["Reference flux tube lon range"] = [np.nan if i<len(self.body_dict) else (self.reference_long_min, self.reference_long_max) for i in range(len(self.body_dict)+1)]

self.pfss_table["Magnetic footpoint (PFSS)"] = photospheric_footpoints
self.pfss_table["Magnetic polarity"] = fieldline_polarities
Expand Down Expand Up @@ -2087,13 +2087,13 @@ def sc_distance(sc1, sc2, dtime):

try:
sc1_coord = get_horizons_coord(sc1, obstime, None)
except ValueError:
except (ValueError, RuntimeError):
print(f"Unable to obtain position for '{sc1}' at {obstime}. Please try a different name or date.")
return np.nan*u.AU
#
try:
sc2_coord = get_horizons_coord(sc2, obstime, None)
except ValueError:
except (ValueError, RuntimeError):
print(f"Unable to obtain position for '{sc2}' at {obstime}. Please try a different name or date.")
return np.nan*u.AU

Expand Down

0 comments on commit 9ca1eed

Please sign in to comment.