Skip to content

Commit

Permalink
update keogram add_axes docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-houghton committed Jul 8, 2024
1 parent 0b98c71 commit f387a6c
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions pyaurorax/tools/classes/keogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,17 @@ def __repr__(self) -> str:

return "Keogram(data=%s, timestamp=%s, ccd_y=%s, mag_y=%s, geo_y=%s)" % (data_str, timestamp_str, ccd_y_str, mag_y_str, geo_y_str)

def set_geographic_latitudes(self, skymap: Skymap, altitude: Optional[Union[int, float]] = None) -> None:
def set_geographic_latitudes(self, skymap: Skymap, altitude_km: Optional[Union[int, float]] = None) -> None:
"""
Set the geographic latitude values for this keogram, using the specified skymap
data. The data will be set to the geo_y attribute of this Keogram object, which
can then be used for plotting and/or further analysis.
Note: currently only specific altitudes are supported at this time, matching the
ones in the passed-in skymap object. A future release will implement an interpolation
routine to allow for a wider range of altitudes.
Args:
skymap (pyaurorax.data.ucalgary.Skymap):
The skymap object to use. This parameter is required.
altitude (int):
altitude_km (int):
The altitude to use, in kilometers. If not specified, it will use the default in the
skymap object. If the specified altitude is not valid, a ValueError will be raised.
Expand All @@ -104,16 +100,16 @@ def set_geographic_latitudes(self, skymap: Skymap, altitude: Optional[Union[int,
"this action not supported at this time.")

# determine altitude index to use
if (altitude is not None):
if (altitude_km is not None):
# Obtain lat/lon arrays from skymap
if (altitude * 1000.0 in skymap.full_map_altitude):
altitude_idx = np.where(altitude * 1000.0 == skymap.full_map_altitude)
if (altitude_km * 1000.0 in skymap.full_map_altitude):
altitude_idx = np.where(altitude_km * 1000.0 == skymap.full_map_altitude)

self.geo_y = np.squeeze(skymap.full_map_latitude[altitude_idx, :, self.__slice_idx]).copy()
else:
# Make sure altitude is in range that can be interpolated
if (altitude * 1000.0 < skymap.full_map_altitude[0]) or (altitude * 1000.0 > skymap.full_map_altitude[2]):
raise ValueError("Altitude " + str(altitude) + " outside valid range of " +
if (altitude_km * 1000.0 < skymap.full_map_altitude[0]) or (altitude_km * 1000.0 > skymap.full_map_altitude[2]):
raise ValueError("Altitude " + str(altitude_km) + " outside valid range of " +
str((skymap.full_map_altitude[0] / 1000.0, skymap.full_map_altitude[2] / 1000.0)))

# Initialze empty lat/lon arrays
Expand All @@ -122,24 +118,20 @@ def set_geographic_latitudes(self, skymap: Skymap, altitude: Optional[Union[int,
# Interpolate lats and lons at desired altitude
for i in range(skymap.full_map_latitude.shape[1]):
for j in range(skymap.full_map_latitude.shape[2]):
lats[i, j] = np.interp(altitude * 1000.0, skymap.full_map_altitude, skymap.full_map_latitude[:, i, j])
lats[i, j] = np.interp(altitude_km * 1000.0, skymap.full_map_altitude, skymap.full_map_latitude[:, i, j])

self.geo_y = lats[:, self.__slice_idx].copy()
else:
# use default middle altitude
self.geo_y = np.squeeze(skymap.full_map_latitude[1,:, self.__slice_idx]).copy()

def set_magnetic_latitudes(self, skymap: Skymap, timestamp: datetime.datetime, altitude: Optional[Union[int, float]] = None) -> None:
def set_magnetic_latitudes(self, skymap: Skymap, timestamp: datetime.datetime, altitude_km: Optional[Union[int, float]] = None) -> None:
"""
Set the magnetic latitude values for this keogram, using the specified skymap
data. AACGMv2 will be utilized to perform the calculations. The resulting data
will be set to the mag_y attribute of this Keogram object, which can then be
used for plotting and/or further analysis.
Note: currently only specific altitudes are supported at this time, matching the
ones in the passed-in skymap object. A future release will implement an interpolation
routine to allow for a wider range of altitudes.
Args:
skymap (pyaurorax.data.ucalgary.Skymap):
The skymap object to use. This parameter is required.
Expand All @@ -148,7 +140,7 @@ def set_magnetic_latitudes(self, skymap: Skymap, timestamp: datetime.datetime, a
The timestamp to use when converting skymap data to magnetic coordinates. Utilizes
AACGMv2 to do the conversion.
altitude (int):
altitude_km (int):
The altitude to use. If not specified, it will use the default in the skymap
object. If the specified altitude is not valid, a ValueError will be raised.
Expand All @@ -165,19 +157,19 @@ def set_magnetic_latitudes(self, skymap: Skymap, timestamp: datetime.datetime, a
"this action not supported at this time.")

# determine altitude index to use
if (altitude is not None):
if (altitude_km is not None):
# Obtain lat/lon arrays from skymap
if (altitude * 1000.0 in skymap.full_map_altitude):
altitude_idx = np.where(altitude * 1000.0 == skymap.full_map_altitude)
if (altitude_km * 1000.0 in skymap.full_map_altitude):
altitude_idx = np.where(altitude_km * 1000.0 == skymap.full_map_altitude)

lats = np.squeeze(skymap.full_map_latitude[altitude_idx, :, :])
lons = np.squeeze(skymap.full_map_longitude[altitude_idx, :, :])
lons[np.where(lons > 180)] -= 360.0

else:
# Make sure altitude is in range that can be interpolated
if (altitude * 1000.0 < skymap.full_map_altitude[0]) or (altitude * 1000.0 > skymap.full_map_altitude[2]):
raise ValueError("Altitude " + str(altitude) + " outside valid range of " +
if (altitude_km * 1000.0 < skymap.full_map_altitude[0]) or (altitude_km * 1000.0 > skymap.full_map_altitude[2]):
raise ValueError("Altitude " + str(altitude_km) + " outside valid range of " +
str((skymap.full_map_altitude[0] / 1000.0, skymap.full_map_altitude[2] / 1000.0)))

# Initialze empty lat/lon arrays
Expand All @@ -187,8 +179,8 @@ def set_magnetic_latitudes(self, skymap: Skymap, timestamp: datetime.datetime, a
# Interpolate lats and lons at desired altitude
for i in range(skymap.full_map_latitude.shape[1]):
for j in range(skymap.full_map_latitude.shape[2]):
lats[i, j] = np.interp(altitude * 1000.0, skymap.full_map_altitude, skymap.full_map_latitude[:, i, j])
lons[i, j] = np.interp(altitude * 1000.0, skymap.full_map_altitude, skymap.full_map_longitude[:, i, j])
lats[i, j] = np.interp(altitude_km * 1000.0, skymap.full_map_altitude, skymap.full_map_latitude[:, i, j])
lons[i, j] = np.interp(altitude_km * 1000.0, skymap.full_map_altitude, skymap.full_map_longitude[:, i, j])

lons[np.where(lons > 180)] -= 360.0

Expand Down

0 comments on commit f387a6c

Please sign in to comment.