Skip to content

Commit

Permalink
Add support for mwmVisit files (#68)
Browse files Browse the repository at this point in the history
* adding mwmvisit to spectra model

* adding mwmvisit to file return path

* bumping specutils version

* updating solara deps

* updating poetry lock file

* relocking
  • Loading branch information
havok2063 authored Jan 10, 2025
1 parent 6aa0530 commit ba72c0c
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 177 deletions.
361 changes: 189 additions & 172 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Sphinx = {version="^3.0.0", optional=true}
fastapi = {extras = ["all"], version = "^0.104.0"}
uvicorn = "^0.22.0"
gunicorn = "^20.1.0"
astropy = "^5.2.0"
astropy = "^6.1.0"
aiofiles = "^0.5.0"
orjson = "^3.9.0"
fastapi-restful = {extras = ["all"], version = "^0.5.0"}
Expand Down
2 changes: 1 addition & 1 deletion python/valis/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class PipeFiles(BaseModel):
""" Pydantic model for lists of files """
boss: Optional[str] = None
apogee: Optional[str] = None
astra: Optional[str] = None
astra: Optional[list[str]] = None


class PipesModel(PeeweeBase):
Expand Down
3 changes: 2 additions & 1 deletion python/valis/db/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ def get_pipe_meta(sdss_id: int, release: str, pipeline: str) -> dict:
# get astra pipeline target
elif pipeline == 'astra' and (qq := get_astra_target(sdss_id, release)):
res = qq.dicts().first()
return {pipeline: res, 'files': {pipeline: build_astra_path(res, release)}}
return {pipeline: res, 'files': {pipeline: [build_astra_path(res, release),
build_astra_path(res, release, name='mwmVisit')]}}


def get_target_pipeline(sdss_id: int, release: str, pipeline: str = 'all') -> dict:
Expand Down
13 changes: 13 additions & 0 deletions python/valis/io/model_spectra_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,18 @@
"error": {"extension": 1, "type": "table", "column": "ivar"},
"mask": {"extension": 1, "type": "table", "column": "pixel_flags"}
}
},
{
"product": "mwmVisit",
"aliases": ["mwmvisit"],
"pipeline": "astra",
"multi_spectra": true,
"spectral_extensions": ["BOSS/APO", "BOSS/LCO", "APOGEE/APO", "APOGEE/LCO"],
"parameters": {
"flux": {"extension": 1, "type": "table", "column": "flux", "units": "1e-17 * erg / (s * cm**2 * Angstrom)"},
"wavelength": {"extension": 1, "type": "wcscon", "column": "LOGLIN", "nwave": "NPIXELS", "units": "Angstrom", "crval": "CRVAL", "cdelt": "CDELT"},
"error": {"extension": 1, "type": "table", "column": "ivar"},
"mask": {"extension": 1, "type": "table", "column": "pixel_flags"}
}
}
]
7 changes: 7 additions & 0 deletions python/valis/io/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ def extract_data(product: str, filepath: str, multispec: Union[int, str] = None)
vals = vals.value

data[param] = vals
elif info['type'] == "wcscon":
# extract the correct wcs header column
npixels = hdulist[extension].header[info['nwave']]
cdelt = hdulist[extension].header[info['cdelt']]
crval = hdulist[extension].header[info['crval']]

data[param] = 10 ** (np.arange(npixels) * cdelt + crval)
else:
data[param] = hdulist[extension].data

Expand Down
7 changes: 5 additions & 2 deletions python/valis/utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def build_apogee_path(values: dict, release: str, ignore_existence: bool = False
ignore_existence=ignore_existence)


def build_astra_path(values: dict, release: str, ignore_existence: bool = False) -> str:
def build_astra_path(values: dict, release: str, name: str = 'mwmStar',
ignore_existence: bool = False) -> str:
""" Build an Astra mwmStar file path
Builds an Astra file path to the mwmStar file. It sets a default
Expand All @@ -168,6 +169,8 @@ def build_astra_path(values: dict, release: str, ignore_existence: bool = False)
the input data values to give to the path template
release : str
the data release
name : str
the name of the file product
ignore_existence : bool, optional
flag to ignore file existence and return path, by default False
Expand All @@ -176,5 +179,5 @@ def build_astra_path(values: dict, release: str, ignore_existence: bool = False)
str
the output file path
"""
return build_file_path(values, 'mwmStar', release, defaults={'component': ''},
return build_file_path(values, name, release, defaults={'component': ''},
ignore_existence=ignore_existence)

0 comments on commit ba72c0c

Please sign in to comment.