Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
samaloney committed Jun 5, 2024
1 parent 356a7d3 commit cc5010f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions stixpy/coordinates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from stixpy.coordinates.transforms import *
1 change: 0 additions & 1 deletion stixpy/coordinates/tests/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from sunpy.map.mapbase import SpatialPair

from stixpy.coordinates.frames import STIXImaging, stix_frame_to_wcs, stix_wcs_to_frame
from stixpy.coordinates.transforms import hpc_to_stixim, stixim_to_hpc # noqa
from stixpy.map.stix import STIXMap


Expand Down
2 changes: 1 addition & 1 deletion stixpy/coordinates/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_hpc_info(start_time, end_time=None):
diff_center = (aux["time"] - time_center).to("s")
closest_index = np.argmin(np.abs(diff_center))

if diff_center[closest_index] > 0:
if diff_center[closest_index] < 0:
start_ind = closest_index - 1
end_ind = closest_index + 1
else:
Expand Down
6 changes: 3 additions & 3 deletions stixpy/product/sources/quicklook.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def time_range(self) -> TimeRange:
"""
A `sunpy.time.TimeRange` for the data.
"""
return TimeRange(self.time[0] - self.exposure_time[0] / 2, self.time + self.exposure_time[-1] / 2)
return TimeRange(self.time[0] - self.exposure_time[0] / 2, self.time[-1] + self.exposure_time[-1] / 2)


class QLLightCurve(QuickLookProduct):
Expand Down Expand Up @@ -132,14 +132,14 @@ def non_thermal_index(self) -> NDArray[str]:
r"""
Flare non-thermal index - significant non-thermal emission
"""
return THERMAL_INDEX_MAP[self.data["thermal_index"]]
return THERMAL_INDEX_MAP[self.data["non_thermal_index"]]

@property
def location_flag(self) -> NDArray[str]:
r"""
Flare location flag
"""
return THERMAL_INDEX_MAP[self.data["thermal_index"]]
return THERMAL_INDEX_MAP[self.data["location_status"]]

def __repr__(self):
return f"{self.__class__.__name__}\n" f" {self.time_range}"
Expand Down
19 changes: 19 additions & 0 deletions stixpy/product/sources/tests/test_quicklook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest
from astropy.coordinates import SkyCoord

from stixpy.product import Product
from stixpy.product.sources import QLFlareFlag


@pytest.mark.remote_data
def test_qlflareflag():
ff = Product(
"https://pub099.cs.technik.fhnw.ch/fits/L1/2024/06/03/QL/" "solo_L1_stix-ql-flareflag_20240603_V02U.fits"
)
assert isinstance(ff, QLFlareFlag)
assert isinstance(ff.flare_location, SkyCoord)
assert ff.location_flag[0, 0] == "None"
assert ff.thermal_index[0, 0] == "Minor"
assert ff.non_thermal_index[0, 0] == "None"

assert True

0 comments on commit cc5010f

Please sign in to comment.