Single-element arrays are read back as scalars from NetCDF files
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start by reading read_from_netcdf, which the issue identifies as returning values[0] for every variable of size 1. Trace how load_events and load_lcurve use its result, then run the NetCDF round-trip examples in the issue. Done means a one-event time remains an array and a one-bin light curve loads successfully.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
A NetCDF file (.nc, the default format) cannot hold a one-element array apart from a scalar: read_from_netcdf returns values[0] for every variable of size 1. So an event list with a single event comes back with time as a scalar, and a light curve with a single bin cannot be loaded at all. The pickle and HDF5 formats round-trip both correctly.
To Reproduce
from stingray import EventList, Lightcurve
from hendrics.io import save_events, load_events, save_lcurve, load_lcurve
save_events(EventList(time=[1.0], gti=[[0, 5]], mjdref=55000.0), "one_ev.nc")
print(load_events("one_ev.nc").time) # 1.0 (a scalar); with "one_ev.p" it is [1.]
lc = Lightcurve([0.5], [3.0], dt=1, gti=[[0, 1]], mjdref=55000.0)
save_lcurve(lc, "one_lc.nc")
load_lcurve("one_lc.nc") # ValueError: time array must be at least 1D
Expected behavior
[1.] and a one-bin light curve, as with the other formats.
Desktop
- OS: macOS
- Python version 3.12
- HENDRICS Version: development from github (main)
- Lingua principale
- Jupyter Notebook
- Stelle
- 26
- Fork
- 18
- Merge medio
- 1h 26m
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di StingraySoftware/HENDRICS
-
memmapped_arange ignores the start value and drops the last point above the memmap thresholdForse già presa @prathameshfuke l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
StingraySoftware/HENDRICS#213 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
StingraySoftware/HENDRICS#198 ·
-
HEN2xspec cannot handle Lomb-Scargle spectraForse di nuovo libera @aviralgarg05 l’ha presa 26 giorni fa e non c’è nessuna pull request aperta. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
StingraySoftware/HENDRICS#197 · 1 commento ·
-
tmp filesAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
StingraySoftware/HENDRICS#174 · 1 commento ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
StingraySoftware/HENDRICS#155 ·
Tutte le issue di StingraySoftware/HENDRICS
Issue simili
-
[TV SHOW]: Dynasty (1981)Apertacountry:US rating:6 request-theme type:TV SHOW
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
LizardByte/ThemerrDB#10501 · 1 commento ·
-
triage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
agentscope-ai/agentscope#4563 ·
I maintainer di solito rispondono entro 2 giorni
-
Split part lines show the bare category name, ordinary booking lines show the full category pathApertabugfix
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
GiroCrab/GiroCrab#2528 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
approved correction metadata
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
acl-org/acl-anthology#11237 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
I maintainer di solito rispondono entro 1 giorno