Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f1539db
Merge pull request #1 from jak574/master
jak574 Nov 15, 2023
8c0bafd
Merge branch 'master' into master
jak574 Feb 2, 2024
ded35e9
Merge pull request #2 from jak574/master
jak574 Feb 2, 2024
ba25a32
Removed errant file
DrPhilEvans May 7, 2024
5975d09
Pulled in some formatting a doc changes that should have been synced …
DrPhilEvans May 7, 2024
5536c23
Pulled in some small documentation fixes
DrPhilEvans May 7, 2024
dc348b0
Add deploy GitHub workflow
jak574 May 7, 2024
64df62a
Merge pull request #4 from Swift-SOT/3-add-deployment-workflow
DrPhilEvans May 8, 2024
6c1ce25
Modifying this to be the latest version of docs
DrPhilEvans May 7, 2024
41badb8
Deleted a file that should only be on dev branch
DrPhilEvans May 7, 2024
8e25201
Merge pull request #5 from Swift-SOT/master
DrPhilEvans May 8, 2024
df7778b
Change references to GitLab to GitHub (#7)
jak574 May 8, 2024
67333eb
Add linting/formatting. Take it easy on the linting for now. Small li…
jak574 May 9, 2024
8bf794d
Fixed various minor python issues giving linting errors. (#11)
DrPhilEvans May 9, 2024
8aa5835
Modified the details of the main README.md, and links in the ChangeLo…
DrPhilEvans May 10, 2024
5264504
Updated description for checkProductStatus method
rini21 May 24, 2024
899ce03
Updated description for checkProductStatus method
rini21 May 24, 2024
46a019c
Updates to fix #14 (#18)
rini21 May 29, 2024
3f4fda6
Added the 'srcrad' parameter to spectra and lc requests, updated all …
DrPhilEvans May 29, 2024
4a90298
Auto generates version.py file from GitHub tags (#22)
jak574 Sep 9, 2024
a8b50f6
Updated ukssdc.query.GRB documentation to reflect the fact that the B…
DrPhilEvans Oct 29, 2024
e5ca189
Merge branch 'main' of github.com:Swift-SOT/swifttools
DrPhilEvans Oct 29, 2024
b5ba0e5
LINTING: Fix use of `!= None` and `== False` (#24)
jak574 Oct 29, 2024
f694660
Fix for crash reading in textual UVOT mode (#26)
jak574 Nov 13, 2024
7ebadf8
Update swift_too changelog and version number (#28)
jak574 Nov 15, 2024
7a80611
Merge branch 'Swift-SOT:main' into master
jak574 Dec 19, 2025
0600977
Merge branch 'Swift-SOT:main' into master
jak574 Dec 21, 2025
b4c453e
Merge branch 'Swift-SOT:main' into master
jak574 Mar 19, 2026
bcc0f7e
Merge branch 'Swift-SOT:main' into master
jak574 Mar 21, 2026
cf4208e
fix: add missing endpoint parameters
jak574 Mar 21, 2026
4ce18ec
fix: align endpoints with openapi.json
jak574 Mar 21, 2026
093a750
fix: tests for constants
jak574 Mar 21, 2026
9c3bb82
fix: broken unit tests
jak574 Mar 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions swifttools/swift_too/swift/calendar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

from pydantic import BaseModel, Field
from pydantic import BaseModel

from ..base.common import TOOAPIBaseclass
from ..base.repr import TOOAPIReprMixin
Expand All @@ -22,8 +22,12 @@ class SwiftCalendarGetSchema(BaseModel):
dec: AstropyAngle | None = None
too_id: int | None = None
radius: AstropyAngle | None = 12 / 60.0
target_id: int | None = None
targetid: int | None = None
status: TOOStatus = Field(default_factory=TOOStatus)
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None


class SwiftCalendarEntry(BaseSchema, TOOAPIClockCorrect, TOOAPIReprMixin):
Expand Down Expand Up @@ -122,7 +126,12 @@ class SwiftCalendarSchema(BaseSchema, TOOAPIReprMixin):
ra: AstropyAngle | None = None
dec: AstropyAngle | None = None
radius: AstropyAngle | None = None
target_id: int | None = None
targetid: int | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None
entries: list[SwiftCalendarEntry] = []
status: TOOStatus = TOOStatus()

Expand Down
9 changes: 8 additions & 1 deletion swifttools/swift_too/swift/guano.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ class SwiftGUANOGetSchema(OptionalBeginEndLengthSchema):
triggertime: datetime | None = None
limit: int | None = None
page: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None
triggertype: str | None = None
queue: int | None = None

model_config = ConfigDict(extra="ignore")

Expand All @@ -209,7 +213,6 @@ def validate_parameters(cls, values):
return
if not isinstance(values, dict):
values = values.__dict__
print(values)
for key in cls.model_fields.keys():
if key in values:
good = True
Expand All @@ -221,10 +224,14 @@ def validate_parameters(cls, values):
class SwiftGUANOSchema(BaseSchema):
begin: datetime | None = None
end: datetime | None = None
username: str = Field(default="anonymous")
subthreshold: bool = False
successful: bool = True
triggertime: datetime | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None
triggertype: str | None = None
lastcommand: datetime | None = None
guanostatus: bool | None = None
Expand Down
10 changes: 10 additions & 0 deletions swifttools/swift_too/swift/obsquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ class SwiftAFSTGetSchema(BaseModel):
radius: AstropyAngle | None = None
target_id: int | list[int] | None = None
obs_id: ObsIDSDC | list[ObsIDSDC] | None = None
gw_event: str | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None

model_config = ConfigDict(extra="ignore")

Expand All @@ -172,6 +177,11 @@ class SwiftAFSTSchema(OptionalCoordinateSchema, OptionalBeginEndLengthSchema):
radius: AstropyAngle | None = None
target_id: int | list[int] | None = None
obs_id: ObsIDSDC | list[ObsIDSDC] | None = None
gw_event: str | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None
afstmax: datetime | SwiftDateTimeSchema | None = None
entries: list[SwiftAFSTEntry] = []
status: TOOStatus = TOOStatus()
Expand Down
8 changes: 8 additions & 0 deletions swifttools/swift_too/swift/planquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class SwiftPPSTGetSchema(OptionalBeginEndLengthSchema, OptionalCoordinateSchema)
radius: AstropyAngle | None = None
target_id: int | list[int] | None = None
obs_id: ObsIDSDC | list[ObsIDSDC] | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None

model_config = ConfigDict(extra="ignore")

Expand Down Expand Up @@ -122,6 +126,10 @@ class SwiftPPSTSchema(OptionalBeginEndLengthSchema, OptionalCoordinateSchema):
radius: AstropyAngle | None = None
target_id: int | list[int] | None = None
obs_id: ObsIDSDC | list[ObsIDSDC] | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None
ppstmax: datetime | None = None
entries: list[SwiftPPSTEntry] = Field(default_factory=list)
status: TOOStatus = Field(default_factory=TOOStatus)
Expand Down
8 changes: 8 additions & 0 deletions swifttools/swift_too/swift/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@


class SwiftTOORequestsGetSchema(OptionalBeginEndLengthSchema, OptionalCoordinateSchema):
username: str | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None
page: int | None = None
year: int | None = None
detail: bool = False
Expand All @@ -28,6 +32,7 @@ def validate_at_least_one_param(cls, data):
if isinstance(data, dict):
# Exclude model_config and other class attributes
params = [
"username",
"begin",
"end",
"length",
Expand All @@ -48,6 +53,9 @@ class SwiftTOORequestsSchema(BaseSchema):
begin: datetime | None = None
length: float | None = None
limit: int | None = None
offset: int | None = None
sort_by: str | None = None
order: str | None = None
year: int | None = None
detail: bool = False
too_id: int | None = None
Expand Down
6 changes: 3 additions & 3 deletions swifttools/swift_too/swift/uvot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SwiftUVOTModeEntry(BaseSchema, TOOAPIReprMixin):
comment on special modes
"""

uvot_mode: int = 0
uvot_mode: int
filter_num: int | None = None
min_exposure: int | None = None
filter_pos: int | None = None
Expand All @@ -62,7 +62,7 @@ class SwiftUVOTModeEntry(BaseSchema, TOOAPIReprMixin):
weight: int | None = None
special: int | None = None
comment: str | None = None
filter_name: str | None = None
filter_name: str


class SwiftUVOTModeSchema(BaseSchema):
Expand Down Expand Up @@ -99,7 +99,7 @@ class SwiftUVOTMode(TOOAPIBaseclass, TOOAPIInstruments, SwiftUVOTModeSchema, TOO

def _post_process(self):
if len(self.entries) == 0:
self.entries = [SwiftUVOTModeEntry(uvot_mode=self.uvot_mode or 0)]
self.entries = [SwiftUVOTModeEntry(uvot_mode=self.uvot_mode or 0, filter_name="")]

def __getitem__(self, index):
return self.entries[index]
Expand Down
12 changes: 12 additions & 0 deletions tests/swift_too/base/common/test_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import importlib


def test_default_swift_too_api_url(monkeypatch):
monkeypatch.delenv("SWIFT_TOO_API_URL", raising=False)

import swifttools.swift_too.base.constants as constants

reloaded = importlib.reload(constants)
expected = f"https://www.swift.psu.edu/api/v{reloaded.API_VERSION}"

assert reloaded.API_URL == expected
45 changes: 45 additions & 0 deletions tests/swift_too/swift/schemas/test_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from datetime import datetime, timedelta

from swifttools.swift_too.swift.schemas import SwiftObservationSchema


class TestSwiftObservationSchema:
def test_settle_field_is_declared(self):
schema = SwiftObservationSchema(
begin=datetime(2023, 1, 1, 12, 0, 0),
settle=datetime(2023, 1, 1, 12, 1, 0),
end=datetime(2023, 1, 1, 12, 10, 0),
)

assert schema.settle == datetime(2023, 1, 1, 12, 1, 0)

def test_time_properties_are_none_safe(self):
schema = SwiftObservationSchema(
begin=datetime(2023, 1, 1, 12, 0, 0),
end=datetime(2023, 1, 1, 12, 10, 0),
)

assert schema.exposure is None
assert schema.slewtime is None

def test_table_uses_none_when_deltas_unavailable(self):
schema = SwiftObservationSchema(
begin=datetime(2023, 1, 1, 12, 0, 0),
end=datetime(2023, 1, 1, 12, 10, 0),
target_name="Test Target",
obs_id="00012345001",
)

_, data = schema._table
assert data[0][4] is None
assert data[0][5] is None

def test_time_properties_when_complete(self):
schema = SwiftObservationSchema(
begin=datetime(2023, 1, 1, 12, 0, 0),
settle=datetime(2023, 1, 1, 12, 1, 0),
end=datetime(2023, 1, 1, 12, 10, 0),
)

assert schema.exposure == timedelta(minutes=9)
assert schema.slewtime == timedelta(minutes=1)
12 changes: 6 additions & 6 deletions tests/swift_too/swift/uvot/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def uvot_mode_with_entries(uvot_mode_empty):

@pytest.fixture
def uvot_entry():
return SwiftUVOTModeEntry(uvot_mode=0x30ED)
return SwiftUVOTModeEntry(uvot_mode=0x30ED, filter_name="")


@pytest.fixture
def sample_uvot_entries():
"""List of sample SwiftUVOTModeEntry objects for testing."""
return [
SwiftUVOTModeEntry(uvot_mode=0x30ED),
SwiftUVOTModeEntry(uvot_mode=0x30ED),
SwiftUVOTModeEntry(uvot_mode=0x30ED, filter_name=""),
SwiftUVOTModeEntry(uvot_mode=0x30ED, filter_name=""),
]


Expand All @@ -57,9 +57,9 @@ def uvot_mode_with_two_entries(uvot_mode_empty, sample_uvot_entries):
def uvot_mode_with_three_entries(uvot_mode_empty):
"""SwiftUVOTMode instance with three entries."""
entries = [
SwiftUVOTModeEntry(uvot_mode=0x30ED),
SwiftUVOTModeEntry(uvot_mode=0x30ED),
SwiftUVOTModeEntry(uvot_mode=0x30ED),
SwiftUVOTModeEntry(uvot_mode=0x30ED, filter_name=""),
SwiftUVOTModeEntry(uvot_mode=0x30ED, filter_name=""),
SwiftUVOTModeEntry(uvot_mode=0x30ED, filter_name=""),
]
uvot_mode_empty.entries = entries
return uvot_mode_empty
2 changes: 1 addition & 1 deletion tests/swift_too/swift/uvot/test_uvot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_init_uvot_mode(self, uvot_entry):
assert uvot_entry.uvot_mode == 0x30ED

def test_init_filter_name(self, uvot_entry):
assert uvot_entry.filter_name is None
assert uvot_entry.filter_name == ""

def test_init_eventmode(self, uvot_entry):
assert uvot_entry.eventmode is None
Expand Down
Loading