gammapy / gamma-sky

Portal to the gamma-ray sky
http://gamma-sky.net/
MIT License
6 stars 3 forks source link

Dump source catalogs to JSON using Gammapy's `_data_python_list` #69

Closed vorugantia closed 7 years ago

vorugantia commented 7 years ago

(The base of this branch was angular4 because everything was working for me so I didn't wait for the PR to be merged.)

In this first commit, I successfully dumped the 3fhl catalog to a JSON file using SourceCatalog3FHL()._data_python_list from Gammapy. However, now we are dumping data in a different format from before - see the difference in key/value structure between cat_3fhl.json and cat_tev.json. Which is the correct format we should use for data dumping?

vorugantia commented 7 years ago

The JSON files are too big to view in GitHub, so either look at them locally or see the sample below.

cat_3fhl.json (Gammapy dump):

[{
  "Source_Name": "3FHL J0001.2-0748 ",
  "RAJ2000": 0.31067517399787903,
  "DEJ2000": -7.807518482208252,
  "GLON": 89.00935363769531,
  "GLAT": -67.31182098388672,
.
.
.
}, {
  "Source_Name": "3FHL J0001.9-4155 ",
  "RAJ2000": 0.48486530780792236,
  "DEJ2000": -41.930259704589844,
  "GLON": 334.1216125488281,
  "GLAT": -72.0697021484375,
.
.
.

cat_tev.json:

{
  "columns": ["Source_Name", "gamma_names", "other_names", .... ],

  "index": [0, 1, 2, 3, 4, ...],

  "data": [
     ["CTA 1", "VER J0006+729", "SNR G119.5+10.2", ...],
     ["Tycho SNR", "", "SNR G120.1+1.4,3C10,SN1572", ...],
     .
     .
     .
   ]

The reason we formatted cat_tev.json like this in the first place (and the other cats) was to make it easier to load each source in the Aladin Lite map.

cdeil commented 7 years ago

@vorugantia - Well, in the end it's up to you, you'll have to adapt the TypeScript processing this in any case. My suggestion would be to go with the simple list of dict approach, I think the other JSON serialisation was something homegrown that we just invented for dumping tables for this webpage. If you're not sure, we can talk about the pros / cons of different formats for this tomorrow afternoon.

vorugantia commented 7 years ago

We decided that this new format (the 3FHL catalog format shown above) is the better way to go. I'll change the format for the other four catalogs we dump to the website and then commit to another PR. Merging for now...