.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/getting_started/data_saving.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_tutorials_getting_started_data_saving.py: ################## Local Data Storage ################## A :class:`ATK.Models.DataSet` of any kind can be stored as a local FITS file. These files can then be read to recreate the original :class:`~ATK.Models.DataSet`. | Automatic Local Data Storage ============================ To store any returned data, :func:`~ATK.Tools.query` can be provided with a ``path``: .. GENERATED FROM PYTHON SOURCE LINES 13-20 .. code-block:: Python from ATK import query target = 2552928187080872832 galex_query = query("vizier", targets=target, survey="galex", path="example_data.fits.gz") .. GENERATED FROM PYTHON SOURCE LINES 28-46 This will automatically save the returned :class:`~ATK.Models.DataSet` to ``path``, and **running the script again will read this local file instead of running** :func:`~ATK.Tools.query` **again.** | .. note:: The following situations will automatically trigger the :func:`~ATK.Tools.query` to run again, overwriting the local file with the updated :class:`~ATK.Models.DataSet`: - Changes to query parameters - Changes to the working version of ATK - If an exception was encountered during data retrieval prior to file creation (i.e. :attr:`~ATK.Models.DataSet.exception` is ``True``) | | Manual Local Data Storage ========================= A :class:`~ATK.Models.DataSet` can also be stored manually by calling its :meth:`~ATK.Models.DataSet.store` method: .. GENERATED FROM PYTHON SOURCE LINES 46-53 .. code-block:: Python from ATK import query target = 2552928187080872832 galex_query = query("vizier", targets=target, survey="galex") galex_query.store("example_data.fits.gz") .. GENERATED FROM PYTHON SOURCE LINES 57-60 | The original :class:`~ATK.Models.DataSet` can be read from the file and re-created with :func:`~ATK.Tools.read`: .. GENERATED FROM PYTHON SOURCE LINES 60-66 .. code-block:: Python from ATK import read data = read("example_data.fits.gz") data.show() .. rst-class:: sphx-glr-script-out .. code-block:: none .kind: Record .targets: 2552928187080872832 | 12.297° 5.377° (icrs, 2016-01-01T00:00:00.000, 3.0″) .exception: False .data: survey: galex catalogue: II/335/galex_ais correction: full search_pos: 12.294° 5.384° (icrs, 2006-08-01T00:00:00.000) table: (astropy.Table) RAJ2000: [12.293] ° DEJ2000: [5.384] ° Name: [GALEX J004910.4+052300] objid: [6380239640935270574] phID: [6380239640934219776] Cat: [AIS] RAfdeg: [12.328] ° DEfdeg: [5.431] ° FUVexp: [216.0] s NUVexp: [216.0] s GLON: [121.884] ° GLAT: [-57.484] ° tile: [50265] img: [801] sv: [25] r.fov: [0.058] ° Obs: [1] b: [1] E(B-V): [0.026000000536441803] mag Sp?: [0] chkf: [0] FUVmag: [nan] mag e_FUVmag: [nan] mag NUVmag: [18.189] mag e_NUVmag: [0.03700000047683716] mag FUV.a: [nan] mag e_FUV.a: [nan] mag NUV.a: [-1.891] mag e_NUV.a: [0.03700000047683716] mag FUV.4: [nan] mag e_FUV.4: [nan] mag NUV.4: [-1.785] mag e_NUV.4: [0.039] mag FUV.6: [nan] mag e_FUV.6: [nan] mag NUV.6: [-1.892] mag e_NUV.6: [0.038] mag Fafl: [0] Nafl: [2] Fexf: [0] Nexf: [0] Fflux: [nan] µJy e_Fflux: [nan] µJy Nflux: [192.502] µJy e_Nflux: [6.567] µJy FXpos: [nan] pix FYpos: [nan] pix NXpos: [1998.98] pix NYpos: [1809.01] pix Fima: [nan] pix Nima: [3.711] pix Fr: [nan] ° Nr: [0.002] ° nS/G: [0.984000027179718] fS/G: [0.0] nell: [0.04500000178813934] fell: [nan] nPA: [-19.420000076293945] ° e_nPA: [-23.059999465942383] ° fPA: [nan] ° e_fPA: [nan] ° Fnr: [13.0] pix F3r: [85.0] pix Nar: [3.5] Narms: [0.001] ° Nbrms: [0.001] ° Far: [nan] Farms: [nan] ° Fbrms: [nan] ° NUVw: [161.3000030517578] s FUVw: [207.1999969482422] s Prob: [nan] Sep: [nan] ″ Nerr: [0.4699999988079071] ″ Ferr: [nan] ″ Ierr: [nan] ″ Nperr: [0.05000000074505806] ″ Fperr: [nan] ″ CV: [C] G: [0] N: [1] primid: [6380239640935270400] groupid: [6380239640935270574] Gd: [0] Nd: [1] primidd: [6380239640935270400] groupidd: [6380239640935270574] groupTot: [6380239640935270574] OName: [N] Size: [nan] pix Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store() .. GENERATED FROM PYTHON SOURCE LINES 70-76 | | File Compression ================ FITS files generated by any of the methods outlined above are **automatically compressed based on the provided extension.** For example, to compress with **gzip**: .. GENERATED FROM PYTHON SOURCE LINES 76-79 .. code-block:: Python galex_query = query("vizier", targets=target, survey="galex", path="example_data.fits.gz") .. GENERATED FROM PYTHON SOURCE LINES 80-81 Or: .. GENERATED FROM PYTHON SOURCE LINES 81-84 .. code-block:: Python galex_query.store("example_data.fits.gz") .. GENERATED FROM PYTHON SOURCE LINES 88-93 | | | .. rubric:: Download this Tutorial .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.749 seconds) .. _sphx_glr_download_auto_tutorials_getting_started_data_saving.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: data_saving.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: data_saving.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: data_saving.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_