Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ jobs:
- graphviz
envs: |
- linux: build_docs
pytest: false
# Speed up CI builds by not building full nav tree
posargs: -D html_theme_options.collapse_navigation=True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested adding a comment that setting this option is specifically for speeding up the CI


online:
if: "!startsWith(github.event.ref, 'refs/tags/v')"
Expand All @@ -108,6 +111,8 @@ jobs:
- graphviz
envs: |
- linux: build_docs-gallery
# Speed up CI builds by not building full nav tree
posargs: -D html_theme_options.collapse_navigation=True
pytest: false
cache-path: |
docs/_build/
Expand Down Expand Up @@ -152,6 +157,12 @@ jobs:
anaconda_token: ${{ secrets.anaconda_org_upload_token }}

publish_pure:
if: |
github.event_name != 'pull_request' ||
(
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Run publish')
)
needs: [test, docs]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v2 # zizmor: ignore[unpinned-uses]
with:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ jobs:
envs: |
- linux: linkcheck
pytest: false
- linux: py314-devdeps-online
posargs: -m "remote_data"
- windows: py313-online
- windows: py314-devdeps-online
posargs: -m "remote_data"

secrets:
Expand Down
1 change: 1 addition & 0 deletions changelog/8637.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the ADAPT client for new filename patterns.
19 changes: 16 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import datetime
import warnings
import tokenize
import logging
from pathlib import Path

from packaging.version import Version
Expand Down Expand Up @@ -39,12 +40,20 @@
from ruamel.yaml import YAML
from sphinx_gallery.sorting import ExplicitOrder
from sunpy_sphinx_theme import PNG_ICON
from sphinx.util import logging as sphinx_logging
sphx_logger = sphinx_logging.getLogger(__name__)

from astropy.utils.exceptions import AstropyDeprecationWarning
from astropy.io.fits.verify import VerifyWarning
import sunpy
from sunpy.util.exceptions import SunpyDeprecationWarning, SunpyPendingDeprecationWarning

# Hide log output during the sphinx build as it pollutes the output
# and makes it harder to see real sphinx warnings
sunpy.log.setLevel(logging.ERROR)
spiceypy_log = logging.getLogger("spiceypy.utils.libspicehelper")
spiceypy_log.setLevel(logging.ERROR)
Comment on lines +54 to +55
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What spiceypy logging messages were showing up?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One log line about where it was loading the compiled library from.


# -- Project information -------------------------------------------------------

# The full version, including alpha/beta/rc tags
Expand Down Expand Up @@ -110,7 +119,11 @@
# This is super slow to check
r"https://mathesaurus\.sourceforge\.net/idl-numpy\.html",
# You have to be logged into GitHub in order to project wide issue searches
r"https://github.com/issues?.*"
r"https://github.com/issues?.*",
# They have an incomplete certificate chain which works in browsers but not CLI
r"https://suit.iucaa.in.*",
# I have no idea why these URLs 403 for linkcheck but pass every other way I try them
r"https://docutils.sourceforge.io/.*",
]
linkcheck_anchors = False
linkcheck_timeout = 120
Expand Down Expand Up @@ -330,7 +343,7 @@ def linkcode_resolve(domain, info):
source, lineno = inspect.getsourcelines(obj)
except (OSError, TypeError, tokenize.TokenError):
if hasattr(obj, '__qualname__'):
print(f"linkcode_resolve: could not get source for {obj.__module__}.{obj.__qualname__}")
sphx_logger.info(f"linkcode_resolve: could not get source for {obj.__module__}.{obj.__qualname__}")
lineno = None

linespec = (f"#L{lineno:d}-L{lineno + len(source) - 1:d}"
Expand Down Expand Up @@ -451,7 +464,7 @@ def jinja_to_rst(app, docname, source):
jinja_pages = ["reference/stability", "dev_guide/index"]
if app.builder.format == 'html':
if docname in jinja_pages:
print(f"Jinja rendering {docname}")
sphx_logger.info(f"Jinja rendering {docname}")
rendered = app.builder.templates.render_string(
source[0], app.config.html_context
)
Expand Down
2 changes: 1 addition & 1 deletion examples/map/track_active_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
a.Wavelength(171*u.angstrom),
a.Sample(1*u.h))
print(query)
files = Fido.fetch(query)
files = Fido.fetch(query, site="NSO")

###############################################################################
# Now that we have a set of images in time, we can create a `~sunpy.map.MapSequence` to hold all of them
Expand Down
1 change: 0 additions & 1 deletion examples/plotting/phi_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# sphinx_gallery_tags = ["Visualization", "SOAR", "Solar Orbiter", "PHI"]

import matplotlib.pyplot as plt
import sunpy_soar # noqa: F401

import sunpy.map
from sunpy.net import Fido
Expand Down
2 changes: 1 addition & 1 deletion examples/time_series/timeseries_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
# involved, but these won't be picked up by `~sunpy.timeseries.TimeSeries`.
# Take care when doing this to ensure dimensional consistency.

df_downsampled = ts_goes_trunc.to_dataframe().resample('10T').mean()
df_downsampled = ts_goes_trunc.to_dataframe().resample('10min').mean()
ts_downsampled = sunpy.timeseries.TimeSeries(df_downsampled,
ts_goes_trunc.meta,
ts_goes_trunc.units)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

lasco_file = hvpy.save_file(hvpy.getJP2Image(parse_time('2000/02/27 07:42').datetime,
hvpy.DataSource.LASCO_C3.value),
get_and_create_download_dir() + "/LASCO_C3.jp2")
get_and_create_download_dir() + "/LASCO_C3.jp2",
overwrite=True)
lasco_map = sunpy.map.Map(lasco_file)

###############################################################################
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ docs-gallery = [
"astroquery>=0.4.6",
"jplephem>=2.19",
"pillow",
"sunpy-soar",
"exifread",
]
dev = ["sunpy[docs,tests]"]
Expand Down
8 changes: 5 additions & 3 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ markers =
remote_data: marks this test function as needing remote data.
online: marks this test function as needing online connectivity.
mpl_image_compare: marks this test function as using hash-based Matplotlib figure verification. This mark is not meant to be directly applied, but is instead automatically applied when a test function uses the @sunpy.tests.helpers.figure_test decorator.
flaky
array_compare
xdist_group
array_compare: pytest-arraydiff for comparing test results with pre-computed arrays.
xdist_group: pytest-xdist marker for grouping tests.
thread_unsafe: pytest-run-parallel marker for tests which are not thread safe.
remote_data_strict = true
# Pin junit behaviour; we might want to update this to xunit2 at some point
junit_family = xunit1
Expand Down Expand Up @@ -77,3 +77,5 @@ filterwarnings =
ignore:Setting the shape on a NumPy array has been deprecated.*:DeprecationWarning:reproject.adaptive.core
# A transient error from Angle.to_string
ignore:invalid value encountered in do_format \(vectorized\):RuntimeWarning
# cdflib triggering a numpy deprecation warning: https://github.com/lasp/cdflib/issues/333
ignore:The \'generic\' unit for NumPy timedelta is deprecated.*:DeprecationWarning
1 change: 1 addition & 0 deletions sunpy-dev-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies:
- pytest-rerunfailures
- pytest-timeout
- pytest-xdist
- pytest-run-parallel
- responses
- tox

Expand Down
39 changes: 20 additions & 19 deletions sunpy/io/special/srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,32 @@ def make_table(header, section_lines, supplementary_lines):
for i, lines in enumerate(section_lines):
if lines:
key = list(meta_data['id'].keys())[i]
t1 = astropy.io.ascii.read(lines)
col_data_types = {
'ID' : np.str_,
'NMBR': np.int64,
'LOCATION': np.str_,
'LO': np.int64,
'AREA': np.int64,
'Z': np.str_,
'LL': np.int64,
'NN': np.int64,
'Magtype': np.bytes_,
'LAT': np.str_,
}
t1 = astropy.io.ascii.read(
lines,
converters=col_data_types,
header_start=0,
guess=False,
format="basic",
)

# Change column names into titlecase
column_names = list(t1.columns)
t1.rename_columns(column_names, new_names=[col.title() for col in column_names])

if len(t1) == 0:
col_data_types = {
# ID : <class 'str'>
'Nmbr': np.dtype('i4'),
'Location': np.dtype('U6'),
'Lo': np.dtype('i8'),
'Area': np.dtype('i8'),
'Z': np.dtype('U3'),
'Ll': np.dtype('i8'),
'Nn': np.dtype('i8'),
'Magtype': np.dtype('S4'),
'Lat': np.dtype('i8'),
}
for c in t1.itercols():
# Put data types of columns in empty table to correct types,
# or else vstack will fail.
c.dtype = col_data_types[c._name]
t1.add_column(
Column(data=None, name="ID", dtype=('S2')), index=0)
t1.add_column(Column(data=None, name="ID", dtype=('S2')), index=0)
else:
t1.add_column(Column(data=[key] * len(t1), name="ID"), index=0)

Expand Down
28 changes: 15 additions & 13 deletions sunpy/io/tests/test_srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
from sunpy.data.test import get_test_filepath
from sunpy.io.special import srs

filenames = [{'file': 'SRS/20150906SRS.txt', 'rows': 5},
{'file': 'SRS/20150306SRS.txt', 'rows': 4},
{'file': 'SRS/20150101SRS.txt', 'rows': 9},
{'file': 'SRS/20100621SRS.txt', 'rows': 3}, # This is a corrected copy
# Uppercase files
{'file': 'SRS/19960106SRS.txt', 'rows': 4}, # inc. spurious `NNN` on final line
{'file': 'SRS/19960430SRS.txt', 'rows': 1},
{'file': 'SRS/19960513SRS.txt', 'rows': 4}, # inc. empty `COMMENT` column
{'file': 'SRS/20000922SRS.txt', 'rows': 10}, # inc. line with `III.`
{'file': 'SRS/20000927SRS.txt', 'rows': 9}, # inc. line with `EFFECTIVE 2 OCT`
{'file': 'SRS/20001001SRS.txt', 'rows': 12}, # inc. line with `COMMENT`
{'file': 'SRS/20020624SRS.txt', 'rows': 14}, # inc. line with `PLAIN`
{'file': 'SRS/20020628SRS.txt', 'rows': 13}] # inc. line with `This message`
filenames = [
{'file': 'SRS/20150906SRS.txt', 'rows': 5},
{'file': 'SRS/20150306SRS.txt', 'rows': 4},
{'file': 'SRS/20150101SRS.txt', 'rows': 9},
{'file': 'SRS/20100621SRS.txt', 'rows': 3}, # This is a corrected copy
# Uppercase files
{'file': 'SRS/19960106SRS.txt', 'rows': 4}, # inc. spurious `NNN` on final line
{'file': 'SRS/19960430SRS.txt', 'rows': 1},
{'file': 'SRS/19960513SRS.txt', 'rows': 4}, # inc. empty `COMMENT` column
{'file': 'SRS/20000922SRS.txt', 'rows': 10}, # inc. line with `III.`
{'file': 'SRS/20000927SRS.txt', 'rows': 9}, # inc. line with `EFFECTIVE 2 OCT`
{'file': 'SRS/20001001SRS.txt', 'rows': 12}, # inc. line with `COMMENT`
{'file': 'SRS/20020624SRS.txt', 'rows': 14}, # inc. line with `PLAIN`
{'file': 'SRS/20020628SRS.txt', 'rows': 13}, # inc. line with `This message`
]

COORDINATES = [{'text': 'N10W05', 'latitude': 10, 'longitude': 5},
{'text': 'N89E00', 'latitude': 89, 'longitude': 0},
Expand Down
77 changes: 16 additions & 61 deletions sunpy/net/dataretriever/sources/adapt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from astropy.time import Time

from sunpy.net import attrs as a
from sunpy.net.dataretriever import GenericClient, QueryResponse
from sunpy.net.dataretriever import GenericClient
from sunpy.net.dataretriever.attrs.adapt import (
ADAPTDataAssimilation,
ADAPTEvolutionMode,
Expand All @@ -15,7 +14,6 @@
ADAPTVersionMonth,
ADAPTVersionYear,
)
from sunpy.time import TimeRange

__all__ = ['ADAPTClient']

Expand All @@ -38,7 +36,7 @@ class ADAPTClient(GenericClient):
>>> CR = 2193
>>> frames = 10
>>> date_start = carrington_rotation_time(CR)
>>> date_end = date_start + frames*(3*1.9999999 * u.hour)
>>> date_end = date_start + frames*(1.9999999 * u.hour)
>>> longitude_type = '0'

>>> Fido.search(a.Time(date_start, date_end), a.Instrument('adapt'), a.adapt.ADAPTLonType(longitude_type)) # doctest: +REMOTE_DATA
Expand All @@ -47,48 +45,33 @@ class ADAPTClient(GenericClient):
<BLANKLINE>
10 Results from the ADAPTClient:
<BLANKLINE>
Start Time End Time Instrument Provider Source ... ADAPTMagData days_since_last_obs hours_since_last_obs minutes_since_last_obs seconds_since_last_obs
----------------------- ----------------------- ---------- -------- ------ ... ------------ ------------------- -------------------- ---------------------- ----------------------
2017-07-20 08:00:00.000 2017-07-20 08:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-20 14:00:00.000 2017-07-20 14:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-20 20:00:00.000 2017-07-20 20:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-21 02:00:00.000 2017-07-21 02:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-21 08:00:00.000 2017-07-21 08:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-21 14:00:00.000 2017-07-21 14:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-21 20:00:00.000 2017-07-21 20:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-22 02:00:00.000 2017-07-22 02:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
2017-07-22 08:00:00.000 2017-07-22 08:00:59.999 ADAPT NSO GONG ... 1 0 4 36 0
2017-07-22 14:00:00.000 2017-07-22 14:00:59.999 ADAPT NSO GONG ... 1 0 1 56 0
Start Time End Time Instrument Provider Source ADAPTFileType ADAPTLonType ADAPTInputSource ...
----------------------- ----------------------- ---------- -------- ------ ------------- ------------ ---------------- ...
2017-07-20 08:00:00.000 2017-07-20 08:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-20 10:00:00.000 2017-07-20 10:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-20 12:00:00.000 2017-07-20 12:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-20 14:00:00.000 2017-07-20 14:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-20 16:00:00.000 2017-07-20 16:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-20 18:00:00.000 2017-07-20 18:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-20 20:00:00.000 2017-07-20 20:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-20 22:00:00.000 2017-07-20 22:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-21 00:00:00.000 2017-07-21 00:00:59.999 ADAPT NSO GONG 4 0 3 ...
2017-07-21 02:00:00.000 2017-07-21 02:00:59.999 ADAPT NSO GONG 4 0 3 ...
<BLANKLINE>
<BLANKLINE>

References
----------
`Names and possible attrs values are available <https://gong.nso.edu/adapt/maps/adapt_filename_notes.txt>`__.
"""
# Pattern described at adapt_filename_notes.txt above.
old_pattern = r'https://gong.nso.edu/adapt/maps/gong/{{year:4d}}/adapt{{ADAPTFileType:1d}}{{ADAPTLonType:1d}}{{ADAPTInputSource:1d}}{{ADAPTDataAssimilation:1d}}{{ADAPTResolution:1d}}' + \
'_{{ADAPTVersionYear:2d}}{{ADAPTVersionMonth:1l}}{{ADAPTRealizations:3d}}_{{year:4d}}{{month:2d}}{{day:2d}}{{hour:2d}}{{minute:2d}}' + \
'_{{ADAPTEvolutionMode:1l}}{{days_since_last_obs:2d}}{{hours_since_last_obs:2d}}{{minutes_since_last_obs:2d}}{{seconds_since_last_obs:2d}}{{ADAPTHelioData:1l}}{{ADAPTMagData:1d}}.fts.gz'

# Pattern since 2024-10-01
new_pattern = r'https://gong.nso.edu/adapt/maps/gong/{{year:4d}}/adapt{{ADAPTFileType:1d}}{{ADAPTLonType:1d}}{{ADAPTInputSource:1d}}{{ADAPTDataAssimilation:1d}}{{ADAPTResolution:1d}}' + \
pattern = r'https://gong.nso.edu/adapt/maps/gong/{{year:4d}}/adapt{{ADAPTFileType:1d}}{{ADAPTLonType:1d}}{{ADAPTInputSource:1d}}{{ADAPTDataAssimilation:1d}}{{ADAPTResolution:1d}}' + \
'_{{ADAPTVersionYear:2d}}{{ADAPTVersionMonth:1d}}{{ADAPTRealizations:3d}}_{{year:4d}}{{month:2d}}{{day:2d}}{{hour:2d}}{{minute:2d}}' + \
'_{{ADAPTEvolutionMode:1l}}{{days_since_last_obs:2d}}{{hours_since_last_obs:2d}}{{minutes_since_last_obs:2d}}{{seconds_since_last_obs:2d}}{{ADAPTHelioData:1l}}{{ADAPTMagData:1d}}.fts.gz'

# Start time of new pattern
new_pattern_start = Time("2024-09-28T01:00:00")

# End time of old pattern
old_pattern_stop = Time("2024-09-30T23:00:00")

@classmethod
def _attrs_module(cls):
return 'adapt', 'sunpy.net.dataretriever.attrs.adapt'

@classmethod
def register_values(cls):
adict = {
return {
a.Instrument: [('ADAPT', 'ADvanced Adaptive Prediction Technique.')],
a.Provider: [('NSO', 'National Solar Observatory.')],
a.Source: [('GONG', 'Global Oscillation Network Group.')],
Expand All @@ -105,31 +88,3 @@ def register_values(cls):
ADAPTMagData: [('0', 'Not added or no data'), ('1', 'Mag-los'), ('2', 'Mag-vector'), ('3', 'Mag- both los & vector'),
('4', 'Mag- polar avg obs'), ('5', 'Mag- los & polar'), ('6', 'Mag- vector & polar'), ('7', 'Mag- both los and vector & polar')]
}
return adict

@classmethod
def pre_search_hook(cls, *args, **kwargs):
"""
Select the appropriate URL pattern based on the time range.
"""
matchdict = cls._get_match_dict(*args, **kwargs)
if kwargs["adapt_use_new_pattern"]:
pattern = cls.new_pattern
else:
pattern = cls.old_pattern
return cls.baseurl, pattern, matchdict

def search(self, *args, **kwargs):
"""
Call super().search with different patterns based on queried time.
"""
matchdict = self._get_match_dict(*args, **kwargs)
tr = TimeRange(matchdict['Start Time'], matchdict['End Time'])
if tr.end < self.new_pattern_start:
return super().search(*args, **kwargs, adapt_use_new_pattern=False)
elif tr.start > self.old_pattern_stop:
return super().search(*args, **kwargs, adapt_use_new_pattern=True)
else:
res1 = super().search(*args, **kwargs, adapt_use_new_pattern=False)
res2 = super().search(*args, **kwargs, adapt_use_new_pattern=True)
return QueryResponse(list(res1)+list(res2), client=self)
2 changes: 1 addition & 1 deletion sunpy/net/dataretriever/sources/goes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class XRSClient(GenericClient):

* Reprocessed 8 - 15: https://www.ncei.noaa.gov/data/goes-space-environment-monitor/access/science/xrs/GOES_1-15_XRS_Science-Quality_Data_Readme.pdf

* GOES-R 16 - 17: https://data.ngdc.noaa.gov/platforms/solar-space-observing-satellites/goes/goes16/l2/docs/GOES-R_XRS_L2_Data_Readme.pdf
* GOES-R 16 - 17: https://data.ngdc.noaa.gov/platforms/solar-space-observing-satellites/goes/goes16/l2/docs/GOES-R_XRS_L2_Data_Users_Guide.pdf

Examples
--------
Expand Down
Loading
Loading