sunpy / sunpy-soar

A sunpy plugin for accessing data in the Solar Orbiter Archive (SOAR).
https://docs.sunpy.org/projects/soar/
BSD 2-Clause "Simplified" License
18 stars 12 forks source link

SOAR Solar Distance Query: Fido Error #155

Closed esdcheliodevops closed 1 month ago

esdcheliodevops commented 1 month ago

Describe the bug

I am encountering an issue with the SOAR solar distance functionality. Here's the relevant documentation link:

https://docs.sunpy.org/projects/soar/generated/gallery/solar_distance_query.html

Before proceeding, I needed to download a specific version because the distance class is not present in sunpy.net.attributes. To resolve this, I checked out this specific commit: https://github.com/sunpy/sunpy-soar/commit/37d1227f0d3341de42413e4475124e6fba36f40d and built it from there.

However, after building, I encountered an internal error related to Fido.

Steps to reproduce:

Expected behavior: The functionality should work as described in the documentation.

Actual behavior: An internal error occurs related to Fido.

To Reproduce

import astropy.units as u
import sunpy.net.attrs as a
from sunpy.net import Fido

import sunpy_soar  # NOQA: F401

import sys
import os

sunpy_soar_path = '/Users/....'
sys.path.insert(0, sunpy_soar_path)

from attrs import Distance  # Adjust based on where Distance is defined

instrument = a.Instrument("EUI")
time = a.Time("2020-10-29 05:00:00", "2022-10-29 06:00:00")
level = a.Level(2)
detector = a.Detector("HRI_EUV")
distance = Distance(0.45 * u.AU, 0.46 * u.AU)

query = instrument & time & level & detector & distance
result = Fido.search(instrument & level & detector & distance)

Screenshots

image

System Details

Astropy version: 6.1.4 SunPy version: 6.0.2 Python version: 3.12.3 sunpy_soar version: 1.11.dev20+g37d1227 macOS 14.6.0

Installation method

pip

Cadair commented 1 month ago

Hi @esdcheliodevops

Thanks for the bug report.

It looks like you are getting in a bit of a muddle with the fact that the SOAR functionality lives in the sunpy_soar package and not sunpy. I am going to move your issue to that repo, just so it's in the right place.

I installed sunpy-soar from git with pip install git+https://github.com/sunpy/sunpy-soar and then modified your code example to be this:

import astropy.units as u
from sunpy.net import Fido, attrs as a

import sunpy_soar # NOQA: F401

import sys
import os

instrument = a.Instrument("EUI")
time = a.Time("2020-10-29 05:00:00", "2022-10-29 06:00:00")
level = a.Level(2)
detector = a.Detector("HRI_EUV")
distance = a.soar.Distance(0.45 * u.AU, 0.46 * u.AU)

query = instrument & time & level & detector & distance
result = Fido.search(instrument & level & detector & distance)
result

and it worked for me.

If you want to install from your checkout of sunpy-soar I suggest you use pip install -e . in the checkout to install sunpy. I would recommend you always steer clear of messing with sys.path

hayesla commented 1 month ago

thanks for raising issue @esdcheliodevops - as @Cadair mentioned the Distance attrs is a specific attribute to sunpy-soar so it needs to be a.soar.Distance similar to a.soar.Product.

Let us know if you are still having issues, or if something is not clear.

esdcheliodevops commented 1 month ago

Thanks @Cadair , @hayesla the code example you provided now works. It seems the issue was with how SunPy was accessing thesunpy-soar module