Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert the "Bounding Box" column in a Fido search result to a SkyCoord column #341

Open
Cadair opened this issue Mar 5, 2024 · 2 comments

Comments

@Cadair
Copy link
Member

Cadair commented Mar 5, 2024

I got this far:

In [105]: res
Out[105]: 
<dkist.net.client.DKISTQueryResponseTable object at 0x7f3db14d3910>
       Start Time               End Time        Instrument               Wavelength                                     Bounding Box                      ... Has Temporal Axis Average Spectral Sampling Average Spatial Sampling Average Temporal Sampling
                                                                             nm                                        arcsec,arcsec                      ...                               nm                     arcsec                      s            
----------------------- ----------------------- ---------- -------------------------------------- ------------------------------------------------------- ... ----------------- ------------------------- ------------------------ -------------------------
2023-10-16T22:02:47.512 2023-10-16T22:03:21.326       VISP 853.7002737559743 .. 854.6361356847904    -69.97999999998137,102.6 .. -141.62999999988824,53.6 ...              True      0.000999852488051306      0.03647318432948004        16.906828252790408

In [105]: coords = np.array(list(map(literal_eval, res["Bounding Box"])))

In [106]: observer = EarthLocation.of_site("DKIST").get_itrs(res["Start Time"])

In [107]: observer = observer.transform_to(sunpy.coordinates.HeliographicStonyhurst(obstime=res["Start Time"]))

In [108]: res["Bounding Box"] = SkyCoord(coords[..., 0], coords[..., 1], unit=u.arcsec, frame="helioprojective", obstime=res["Start Time"][:, None], observer=observer[:, None])
@Cadair
Copy link
Member Author

Cadair commented Mar 5, 2024

Note: The dataset API uses top_right, lower_left ordering and sunpy uses lower_left, top_right everywhere so we might want to flip them around to match the sunpy convention.

@Cadair
Copy link
Member Author

Cadair commented Mar 5, 2024

Here's a complete implementation of a function which transforms the BoundingBox coord:

def dkist_fido_convert_bb(res):
    res = res.copy()
    coords = np.array(list(map(literal_eval, res["Bounding Box"])))
    observer = EarthLocation.of_site("DKIST").get_itrs(res["Start Time"])
    observer = observer.transform_to(sunpy.coordinates.HeliographicStonyhurst(obstime=res["Start Time"]))
    res["Bounding Box"] = SkyCoord(coords[..., 0][:, ::-1], coords[..., 1][:, ::-1], unit=u.arcsec, frame="helioprojective", obstime=res["Start Time"][:, None], observer=observer[:, None])
    return res

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant