Single-element arrays are read back as scalars from NetCDF files

オープン
#211 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@prathameshfuke がすでに取り組んでいます。

2026年12月5日 から。

  • #212 @prathameshfuke による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
data

調査の方向性

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

StingraySoftware/HENDRICS のほかの issue

StingraySoftware/HENDRICS の issue をすべて見る

似ている issue

Data Engineering の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。