Skip to content
Snippets Groups Projects
Commit f25b2529 authored by Michele Maris's avatar Michele Maris
Browse files

u added docs for sphinx

parent 0a368797
No related branches found
No related tags found
No related merge requests found
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
docs contains documentation produced by sphinx
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
This diff is collapsed.
ADQL Queries
============
A query is a string with format
<DIRECTIVE> [expression [<DIRECTIVE> ....]]
Valid directives are
SELECTION
set of data to be selected
HOW_MANY
elements to select
WHICH_FIELDS
fields to select
FROM
which table to be queried
WHERE
condition for elements selection
Examples of query strings:
1. Download all the data:
::
`SELECT * FROM exo.EXO`
2. Download only the first 10 elements:
::
`SELECT TOP 10 * FROM exo.EXO`
3. Download only the first 10 elements with SMA in the range 0.9 to 1.1:
::
`SELECT TOP 10 * FROM exo.EXO WHERE SMA BETWEEN 0.9 AND 1.1`
4. The same but with a different expression
::
`SELECT TOP 10 * FROM exo.EXO WHERE (0.9 <= SMA) AND (SMA <= 1.1)`
5. Download only the first 10 elements with SMA in the range 0.9 to 1.1 and CONTHAB>=0.5
::
`SELECT TOP 10 * FROM exo.EXO WHERE SMA BETWEEN 0.9 AND 1.1 AND CONTHAB>=0.5`
6. Arithmetic calculations are allowed if needed for selection so to download the first 10 elements with SMA^1.5 > 0.87
::
`SELECT TOP 10 * FROM exo.EXO WHERE power(SMA,1.5)> 0.87`
7. returns just columns SMA and CONTHAB from previous example:
::
`SELECT TOP 10 SMA,CONTHAB FROM exo.EXO WHERE power(SMA,1.5)> 0.87`
Note that a query string is not sensitive to uppercase or lowercase.
For other details see:
- http://www.g-vo.org/tutorials/gaia-mock-tap.pdf
- http://www.ivoa.net/documents/REC/ADQL/ADQL-20081030.pdf
- http://www.ivoa.net/documents/
An inline reminder of how to form query strings can be recalled by:
>>> atap.EXPLAIN()
API
===
.. autosummary:: py_artecs
:toctree:
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
#sys.path.insert(0, os.path.abspath(os.getcwd()+'/src'))
sys.path.insert(0, '../src')
#print(sys.path)
# -- Project information -----------------------------------------------------
project = 'py_artecs'
copyright = '2023, M.Maris, M.Molinaro'
author = 'M.Maris, M.Molinaro'
# The full version, including alpha/beta/rc tags
release = '1.0.1'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.duration',
'sphinx.ext.doctest',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'autoapi.extension',
'sphinx.ext.inheritance_diagram',
]
autoapi_type='python'
autoapi_dirs = ['../../src/py_artecs']
autoapi_options: [ 'members', 'show-inheritance', 'show-inheritance-diagram', 'special-members', 'imported-members']
#autoapi_options: [ 'members', 'private-members', 'show-inheritance', 'show-module-summary', 'special-members', 'imported-members', 'undoc-members']
#autoapi_options= ['members']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
How to Quote
============
If you use this library of parts of it for your work, please quote:
*Climate bistability of Earth-like exoplanets*
Murante G., Provenzale A., Vladilo G.,Taffoni G., Silva L., Palazzi E.,von Hardenberg J.,Maris M., Londero E., Knapic C., Zorba C.
MNRAS **492**, 2638–2650 (2020)
https://doi.org/10.1093/mnras/stz3529
.. py_artecs documentation master file, created by
sphinx-quickstart on Wed May 24 10:11:21 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to py_artecs's documentation!
=====================================
The library py_artecs is designed to provide an user friendly interface to the `ARTECS http://wwwuser.oats.inaf.it/exobio/climates/' database of exoplanets climates through TAP and PyVO services.
It was originally authored in 2019 by Michele Maris and Marco Molinaro.
The library allows to query the database for a list of models, download the list and for each model download the corresponding fits file containing the exoplanet temperature map.
The library also provides a class to simplify the handling of a temperature map file.
Check out section :ref:`Install <installation>` to install the project and section :doc:`Usage <usage>` for an example of usage.
-------
.. toctree::
:maxdepth: 3
:caption: Contents:
installation
usage
adql
miscellanea
howtoquote
-------------------
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. _installation:
Installation
============
To install by pip
-----------------
To install with pip3:
.. code-block:: console
$ pip3 install py_artecs
To clone the dev version
------------------------
To clone the development version from the GitLab of National Institute of Astrophysics
.. code-block:: console
$ git clone https://www.ict.inaf.it/gitlab/michele.maris/py_artecs
Note that in this case the library will be in ./py_artecs/src/py_artecs.
To install pyvo
---------------
The package pyvo should be part of astropy. To install separately
.. code-block:: console
$ sudo pip3 install pyvo
Miscellanea
===========
Example of session with TAP
---------------------------
It is possible to access the archive directly with TAP
>>> import pyvo as vo
>>> tap_service = vo.dal.TAPService("http://archives.ia2.inaf.it/vo/tap/exo")
>>> tap_results = tap_service.search("SELECT top 1 exp_id, url FROM exo.EXO")
>>> print(tap_results)
>>>...
>>> len(tap_results)
>>>...
>>> tap_results.getrecord(0)
>>>...
py\_artecs
==========
.. automodule:: py_artecs
:members:
Usage
=====
Basic query
-----------
The archive is accessed from exop_pubblic_tap in py_artecs:
>>> from artecs import exop_pubblic_tap
Then instantiate a database session named "atap"
>>> atap=exop_pubblic_tap()
all the queries to ARTECS are made through the methods in atap.
Queries follows the Astronomical Data Query Language (ADQL) format
>>> ptab=atap.search('power(SMA,1.5)>0.87');
see the appendix for further references on the ADQL.
To know wether the search is successfull:
>>> atap.success()
True
Before a new query the atap has to be resetted width:
>>> atap.clear()
Results in pandas table
-----------------------
The result of a query is stored in "ptab" as a PANDAS data_frame.
In order to save the table as a csv file use the "to_csv" method of pandas data frame:
>>> ptab.to_csv('result.csv',sep=' ')
Getting temperature maps
------------------------
In order to get a map corresponding to the first entry in the ptab use:
>>> TMAP=atap.get_map(ptab[0].URL)
the command creates a fits file to download the fits file specified in ptab[0].URL
>>> print(MAP.filename)
/tmp/artecs_download_file_669d40064f5bddc8.fits
note that the get_map method saved the fits inside the /tmp directory and gives it a dummy name.
To specify a different name and directory use the outfile keyword in get_map
>>> TMAP=atap.get_map(ptab[0].URL,outfile='./test.fits')
>>> print(TMAP.filename)
./test.fits
TMAP is an object of class artecs_map, so it contains the temperature MAP in the ARTECS fits file, as well as the other keywords in the original fits file.
Note that the artecs_map class can be used also local copies of the ARTECS temperature maps.
Usage
=====
.. _installation:
Installation
------------
To use py_artecs, firt install it by using pip3:
.. code-block:: console
$ pip3 install py_artecs
If you want to download the development version download it from inaf GitLab with
.. code-block:: console
$ git clone https://www.ict.inaf.it/gitlab/michele.maris/py_artecs
in this case the library will be in py_artecs/src/py_artecs.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment