Single-element arrays are read back as scalars from NetCDF files
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- Jupyter Notebook
- スター
- 26
- フォーク
- 18
- 平均マージ
- 1時間 26分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
StingraySoftware/HENDRICS のほかの issue
-
memmapped_arange ignores the start value and drops the last point above the memmap threshold対応中かも @prathameshfuke が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
StingraySoftware/HENDRICS#213 ·
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
StingraySoftware/HENDRICS#198 ·
-
HEN2xspec cannot handle Lomb-Scargle spectra再び着手できるかも @aviralgarg05 が 26 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
StingraySoftware/HENDRICS#197 · コメント 1 件 ·
-
tmp filesオープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
StingraySoftware/HENDRICS#174 · コメント 1 件 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
StingraySoftware/HENDRICS#155 ·
StingraySoftware/HENDRICS の issue をすべて見る
似ている issue
-
country:US rating:6 request-theme type:TV SHOW
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
LizardByte/ThemerrDB#10501 · コメント 1 件 ·
-
triage/confirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
agentscope-ai/agentscope#4563 ·
メンテナーはふだん 2 日以内に返信
-
review
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
Split part lines show the bare category name, ordinary booking lines show the full category pathオープンbugfix
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
GiroCrab/GiroCrab#2528 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
approved correction metadata
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
acl-org/acl-anthology#11237 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信