Migrating from pyNEID
nexsci-rv replaces pyNEID. It covers
the same NEID searches and downloads, but it is not API-compatible: there is
no compatibility shim, so existing code is rewritten call by call. This page is
the mapping.
The biggest change is that queries return an astropy Table instead
of writing a file to outpath, and download takes that table instead of
a path to a saved metadata file.
Setup and login
# pyNEID
from pyneid.neid import Neid
Neid.login(userid="me", password="...", cookiepath="./neidcookie.txt")
# nexsci-rv
from nexsci_rv import NEIDArchive
neid = NEIDArchive()
neid.login(username="me", password="...")
There is no
cookiepath. The session cookie is stored for you (under~/.config/nexsci-rv/neid/) and reused by every later query and download, in this and future sessions.Credentials can come from the environment instead of code:
NEXSCI_RV_NEID_USERandNEXSCI_RV_NEID_PASSWORD. With neither arguments nor environment variables,login()prompts.Public data needs no login at all, as before.
Method mapping
pyNEID |
nexsci-rv |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Arguments that changed shape
Date ranges are a (start, end) tuple instead of a "start/end" string.
Either side may be None for an open range, replacing pyNEID’s "t1/" and
"/t2" forms. Strings, datetime objects, and astropy.time.Time all work.
Positions are a coordinate plus a radius instead of a "circle ra dec r"
string. The coordinate is an astropy.coordinates.SkyCoord or an
(ra, dec) tuple in degrees; a bare-number radius is in degrees, or pass an
astropy angle such as 30 * u.arcsec. pyNEID’s polygon and box shapes
have no high-level equivalent — write them with query_adql using
ADQL’s POLYGON / BOX against the qrad / qdecd columns.
query_object radius: pyNEID searched within 0.5 degrees of the
resolved name by default; nexsci-rv defaults to 30 arcseconds. Pass
radius=0.5 * u.deg to reproduce pyNEID’s result sets exactly.
query_pi matches the PI column exactly, as pyNEID’s query_piname did:
pass the full name as the archive stores it (e.g. "Robert Mathieu").
query_criteria keys:
pyNEID |
nexsci-rv |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nexsci-rv adds a where key for an extra raw ADQL condition.
maxrec works as before. format is now output_format= and only
affects how results travel over the wire — you always get a Table back.
pyNEID’s tsv format is not offered.
Saving results
Where pyNEID wrote the result to outpath, write the returned table yourself in
whatever format you want:
table = neid.query_datetime("l2", ("2024-11-01", "2024-11-06"))
table.write("l2_results.tbl", format="ascii.ipac")
Downloading
# pyNEID
Neid.download("./criteria.tbl", "l2", "ipac", "./dnload_dir",
cookiepath="mycookie", start_row=0, end_row=10)
# nexsci-rv
paths = neid.download(table[0:10], outdir="./dnload_dir")
Pass the table a query returned. It remembers its data level, so
downloadfetches the right files — an L2 result downloads L2 spectra.start_row/end_rowbecome ordinary table slicing.If you saved a table to disk and read it back with
Table.read, it no longer knows its data level: pass it explicitly, e.g.neid.download(table, outdir="data/", data_level="l2").downloadreturns a list ofpathlib.Paths. Files that fail are retried and then reported together in aDownloadErrorwhile the successful files stay on disk.
Note
pyNEID’s calibfile=1 option, which also fetched each observation’s
associated calibration files, has no equivalent in nexsci-rv yet.
Errors
pyNEID reported many failures by printing or by returning a status. nexsci-rv
raises typed exceptions from nexsci_rv.exceptions — for example
TapServerError with the server’s message when a
query fails, and AuthExpired when a session
needs a fresh login(). Catch NexsciRVError to
handle anything from the package.