Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.

Commit c361efc

Browse files
author
Dominik Neise
authored
Merge pull request #24 from cta-sst-1m/working_on_v0.44.4
Working on v0.44.4
2 parents 60e02c5 + a35afbe commit c361efc

3 files changed

Lines changed: 634 additions & 35 deletions

File tree

README.md

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,35 @@ If you are just starting with proto-z-fits files and would like to explore the f
1010
### Open a file
1111
```python
1212
>>> from protozfits import SimpleFile
13-
>>> example_path = 'protozfits/tests/resources/example_100evts.fits.fz'
13+
>>> example_path = 'protozfits/tests/resources/example_9evts_NectarCAM.fits.fz'
1414
>>> file = SimpleFile(example_path)
1515
>>> file
16-
File({'Events': Table(100xCameraEvent)})
16+
File({
17+
'RunHeader': Table(1xCameraRunHeader),
18+
'Events': Table(9xCameraEvent)
19+
})
1720
```
1821

1922
From this we learn, the `file` contains a single `Table` named `Events` which
2023
contains 100 rows of type `CameraEvent`. There might be more tables with
2124
other types of rows in other files.
2225

23-
### Table header
26+
### RunHeader
27+
28+
Even though there is usually **only one** run header per file, technically
29+
this single run header is stored in a Table. This table could contain multiple
30+
"rows" and to me it is not clear what this would mean... but technically it is
31+
possible.
32+
33+
At the moment I would recommend getting the run header out of the file
34+
we opened above like this:
2435

25-
`fits.fz` files are still normal [FITS files](https://fits.gsfc.nasa.gov/) and
26-
each Table in the file corresponds to a so called "BINTABLE" extension, which has a
27-
header. You can access this header like this:
2836
```python
29-
>>> file.Events
30-
Table(100xCameraEvent)
31-
>>> file.Events.header
32-
# this is just a sulection of all the contents of the header
33-
XTENSION= 'BINTABLE' / binary table extension
34-
BITPIX = 8 / 8-bit bytes
35-
NAXIS = 2 / 2-dimensional binary table
36-
NAXIS1 = 192 / width of table in bytes
37-
NAXIS2 = 1 / number of rows in table
38-
TFIELDS = 12 / number of fields in each row
39-
EXTNAME = 'Events' / name of extension table
40-
CHECKSUM= 'BnaGDmS9BmYGBmY9' / Checksum for the whole HDU
41-
DATASUM = '1046602664' / Checksum for the data block
42-
DATE = '2017-10-31T02:04:55' / File creation date
43-
ORIGIN = 'CTA' / Institution that wrote the file
44-
WORKPKG = 'ACTL' / Workpackage that wrote the file
45-
DATEEND = '1970-01-01T00:00:00' / File closing date
46-
PBFHEAD = 'DataModel.CameraEvent' / Written message name
47-
CREATOR = 'N4ACTL2IO14ProtobufZOFitsE' / Class that wrote this file
48-
COMPILED= 'Oct 26 2017 16:02:50' / Compile time
49-
TIMESYS = 'UTC' / Time system
50-
>>> file.Events.header['DATE']
51-
'2017-10-31T02:04:55'
52-
>>> type(file.Events.header)
53-
<class 'astropy.io.fits.header.Header'>
37+
>>> # because we do not know what to do, if there are 2 run headers
38+
>>> assert len(file.RunHeader) == 1
39+
>>> # Tables need to be iterated over ... next gives the next row ...
40+
>>> header = next(file.RunHeader)
5441
```
55-
The header is provided by [`astropy`](http://docs.astropy.org/en/stable/io/fits/#working-with-fits-headers).
5642

5743
### Getting an event
5844

@@ -110,6 +96,40 @@ CameraEvent(
11096
# [...]
11197
```
11298

99+
### Table header
100+
101+
`fits.fz` files are still normal [FITS files](https://fits.gsfc.nasa.gov/) and
102+
each Table in the file corresponds to a so called "BINTABLE" extension, which has a
103+
header. You can access this header like this:
104+
```python
105+
>>> file.Events
106+
Table(100xCameraEvent)
107+
>>> file.Events.header
108+
# this is just a sulection of all the contents of the header
109+
XTENSION= 'BINTABLE' / binary table extension
110+
BITPIX = 8 / 8-bit bytes
111+
NAXIS = 2 / 2-dimensional binary table
112+
NAXIS1 = 192 / width of table in bytes
113+
NAXIS2 = 1 / number of rows in table
114+
TFIELDS = 12 / number of fields in each row
115+
EXTNAME = 'Events' / name of extension table
116+
CHECKSUM= 'BnaGDmS9BmYGBmY9' / Checksum for the whole HDU
117+
DATASUM = '1046602664' / Checksum for the data block
118+
DATE = '2017-10-31T02:04:55' / File creation date
119+
ORIGIN = 'CTA' / Institution that wrote the file
120+
WORKPKG = 'ACTL' / Workpackage that wrote the file
121+
DATEEND = '1970-01-01T00:00:00' / File closing date
122+
PBFHEAD = 'DataModel.CameraEvent' / Written message name
123+
CREATOR = 'N4ACTL2IO14ProtobufZOFitsE' / Class that wrote this file
124+
COMPILED= 'Oct 26 2017 16:02:50' / Compile time
125+
TIMESYS = 'UTC' / Time system
126+
>>> file.Events.header['DATE']
127+
'2017-10-31T02:04:55'
128+
>>> type(file.Events.header)
129+
<class 'astropy.io.fits.header.Header'>
130+
```
131+
The header is provided by [`astropy`](http://docs.astropy.org/en/stable/io/fits/#working-with-fits-headers).
132+
113133
### Isn't this a little slow?
114134

115135
Well, indeed, converting the original google protobuf instances into namedtuples full of
@@ -157,11 +177,11 @@ You do not have to use a [conda environment](https://conda.io/docs/user-guide/ta
157177

158178
### Linux (with anaconda)
159179

160-
pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.44.3.tar.gz
180+
pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.44.4.tar.gz
161181

162182
### OSX (with anaconda)
163183

164-
pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.44.3.tar.gz
184+
pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.44.4.tar.gz
165185

166186
To use it you'll have to find your `site-packages` folder, e.g. like this:
167187

protozfits/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.44.3
1+
0.44.4

protozfits/tests/resources/example_9evts_NectarCAM.fits.fz

Lines changed: 579 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)