astrocalc Documentation

astrocalc Documentation
Release 0.2.4
Dave Young
2017
Getting Started
1
Installation
1.1 Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
3
4
2
Command-Line Usage
5
3
Documentation
7
4
Command-Line Tutorial
9
5
Installation
5.1 Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
11
12
6
Command-Line Usage
13
7
Documentation
15
8
Command-Line Tutorial
8.1 Subpackages . . . . . . . . . . . . . . . . . . .
8.1.1
astrocalc (subpackage) . . . . . . . . .
8.1.2
astrocalc.commonutils (subpackage) . .
8.1.3
astrocalc.coords (subpackage) . . . . .
8.1.4
astrocalc.distances (subpackage) . . . .
8.1.5
astrocalc.times (subpackage) . . . . . .
8.2 Modules . . . . . . . . . . . . . . . . . . . . .
8.2.1
astrocalc.cl_utils (module) . . . . . . .
8.3 Classes . . . . . . . . . . . . . . . . . . . . . .
8.3.1
astrocalc.coords.separations (class) . . .
8.3.1.0.1
Methods . . . . . . .
8.3.2
astrocalc.coords.translate (class) . . . .
8.3.2.0.1
Methods . . . . . . .
8.3.3
astrocalc.coords.unit_conversion (class)
8.3.3.0.1
Methods . . . . . . .
8.3.4
astrocalc.distances.converter (class) . .
8.3.4.0.1
Methods . . . . . . .
8.3.5
astrocalc.times.conversions (class) . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
17
17
17
18
18
18
18
18
18
19
19
20
20
21
21
22
22
22
22
i
8.3.5.0.1
Methods . . . . . . . . . . . .
astrocalc.times.now (class) . . . . . . . . . . . .
8.3.6.0.1
Methods . . . . . . . . . . . .
Functions . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4.1
astrocalc.luminosity_to_flux (function) . . . . . .
8.4.2
astrocalc.coords.coordinates_to_array (function) .
8.4.3
astrocalc.cl_utils.tab_complete (function) . . . .
Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . .
Todo . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.6
8.4
8.5
8.6
Python Module Index
ii
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
23
23
23
23
24
24
24
25
25
27
astrocalc Documentation, Release 0.2.4
An astronomer’s calculator used to perform common calculations, conversions and measurements..
astrocalc is both a python package and a suite command-line tools.
Here’s a summary of what’s included in the python package:
Classes
astrocalc.coords.separations
astrocalc.coords.translate
astrocalc.coords.unit_conversion
astrocalc.distances.converter
astrocalc.times.conversions
astrocalc.times.now
The worker class for the separations module
Translate a set of coordinates north and east by distances
given in arcsecs
The worker class for the unit_conversion module
A converter to switch distance between various units of
measurement
The worker class for the conversions module
Report the current time into various formats
Functions
astrocalc.luminosity_to_flux
astrocalc.coords.coordinates_to_array
Convert luminosity to a flux
Convert a single value RA, DEC or list of RA and DEC to
numpy arrays
astrocalc.cl_utils.tab_complete
Getting Started
1
astrocalc Documentation, Release 0.2.4
2
Getting Started
CHAPTER
1
Installation
The easiest way to install astrocalc is to use pip:
pip install astrocalc
Or you can clone the github repo and install from a local version of the code:
git clone [email protected]:thespacedoctor/astrocalc.git
cd astrocalc
python setup.py install
To upgrade to the latest version of astrocalc use the command:
pip install astrocalc --upgrade
Please also install numpy
pip install numpy
Development
If you want to tinker with the code, then install in development mode. This means you can modify the code from your
cloned repo:
git clone [email protected]:thespacedoctor/astrocalc.git
cd astrocalc
python setup.py develop
Pull requests are welcomed!
3
astrocalc Documentation, Release 0.2.4
Issues
Please report any issues here.
4
Chapter 1. Installation
CHAPTER
2
Command-Line Usage
Documentation for astrocalc can be found here: http://astrocalc.readthedocs.org/en/
˓→stable
Usage:
astrocalc
astrocalc
astrocalc
astrocalc
astrocalc
astrocalc
[-c] coordflip <ra> <dec>
sep <ra1> <dec1> <ra2> <dec2>
timeflip <datetime>
trans <ra> <dec> <north> <east>
now mjd
dist (-z | -m) <distVal> [--hc=hVal --wm=OmegaMatter --wv=OmegaVacuum]
COMMANDS:
========
coordflip
˓→sexegesimal and vice-versa
sep
˓→sky.
timeflip
trans
˓→arcsec)
now
dist
flip coordinates between decimal degrees and
calculate the separation between two locations in the
flip time between UT and MJD.
translate a location across the sky (north and east in
report current time in various formats
convert distance between mpc to z
VARIABLES:
==========
ra, ra1, ra2
right-ascension in deciaml degrees or sexegesimal format
dec, dec1, dec2
declination in deciaml degrees or sexegesimal format
datetime
modified julian date (mjd) or universal time (UT). UT
˓→can be formated 20150415113334.343 or "20150415 11:33:34.343" (spaces require
˓→quotes)
north, east
vector components in arcsec
distVal
a distance value in Mpc (-mpc) or redshift (-z)
hVal
hubble constant value. Default=70 km/s/Mpc
OmegaMatter
Omega Matter. Default=0.3
5
astrocalc Documentation, Release 0.2.4
OmegaVacuum
-h,
-m,
-z,
-c,
6
--help
--mpc
--redshift
--cartesian
Omega Vacuum. Default=0.7
show this help message
distance in mpc
redshift distance
convert to cartesian coordinates
Chapter 2. Command-Line Usage
CHAPTER
3
Documentation
Documentation for astrocalc is hosted by Read the Docs (last stable version and latest version).
7
astrocalc Documentation, Release 0.2.4
8
Chapter 3. Documentation
CHAPTER
4
Command-Line Tutorial
Todo
• add tutorial
9
astrocalc Documentation, Release 0.2.4
10
Chapter 4. Command-Line Tutorial
CHAPTER
5
Installation
The easiest way to install astrocalc is to use pip:
pip install astrocalc
Or you can clone the github repo and install from a local version of the code:
git clone [email protected]:thespacedoctor/astrocalc.git
cd astrocalc
python setup.py install
To upgrade to the latest version of astrocalc use the command:
pip install astrocalc --upgrade
Please also install numpy
pip install numpy
Development
If you want to tinker with the code, then install in development mode. This means you can modify the code from your
cloned repo:
git clone [email protected]:thespacedoctor/astrocalc.git
cd astrocalc
python setup.py develop
Pull requests are welcomed!
11
astrocalc Documentation, Release 0.2.4
Issues
Please report any issues here.
12
Chapter 5. Installation
CHAPTER
6
Command-Line Usage
Documentation for astrocalc can be found here: http://astrocalc.readthedocs.org/en/
˓→stable
Usage:
astrocalc
astrocalc
astrocalc
astrocalc
astrocalc
astrocalc
[-c] coordflip <ra> <dec>
sep <ra1> <dec1> <ra2> <dec2>
timeflip <datetime>
trans <ra> <dec> <north> <east>
now mjd
dist (-z | -m) <distVal> [--hc=hVal --wm=OmegaMatter --wv=OmegaVacuum]
COMMANDS:
========
coordflip
˓→sexegesimal and vice-versa
sep
˓→sky.
timeflip
trans
˓→arcsec)
now
dist
flip coordinates between decimal degrees and
calculate the separation between two locations in the
flip time between UT and MJD.
translate a location across the sky (north and east in
report current time in various formats
convert distance between mpc to z
VARIABLES:
==========
ra, ra1, ra2
right-ascension in deciaml degrees or sexegesimal format
dec, dec1, dec2
declination in deciaml degrees or sexegesimal format
datetime
modified julian date (mjd) or universal time (UT). UT
˓→can be formated 20150415113334.343 or "20150415 11:33:34.343" (spaces require
˓→quotes)
north, east
vector components in arcsec
distVal
a distance value in Mpc (-mpc) or redshift (-z)
hVal
hubble constant value. Default=70 km/s/Mpc
OmegaMatter
Omega Matter. Default=0.3
13
astrocalc Documentation, Release 0.2.4
OmegaVacuum
-h,
-m,
-z,
-c,
14
--help
--mpc
--redshift
--cartesian
Omega Vacuum. Default=0.7
show this help message
distance in mpc
redshift distance
convert to cartesian coordinates
Chapter 6. Command-Line Usage
CHAPTER
7
Documentation
Documentation for astrocalc is hosted by Read the Docs (last stable version and latest version).
15
astrocalc Documentation, Release 0.2.4
16
Chapter 7. Documentation
CHAPTER
8
Command-Line Tutorial
Todo
• add tutorial
Subpackages
astrocalc
astrocalc.commonutils
astrocalc.coords
astrocalc.distances
astrocalc.times
common tools used throughout package
Calculations and conversions based on sky-coordinates
Tools to work with and manipulate astronomical distances
Calculations and conversions based on astronomical times
astrocalc (subpackage)
astrocalc.luminosity_to_flux(lumErg_S, dist_Mpc)
Convert luminosity to a flux
Key Arguments:
• lumErg_S – luminosity in ergs/sec
• dist_Mpc – distance in Mpc
Return:
• fluxErg_cm2_S – flux in ergs/cm2/s
17
astrocalc Documentation, Release 0.2.4
astrocalc.commonutils (subpackage)
common tools used throughout package
astrocalc.coords (subpackage)
Calculations and conversions based on sky-coordinates
astrocalc.distances (subpackage)
Tools to work with and manipulate astronomical distances
astrocalc.times (subpackage)
Calculations and conversions based on astronomical times
Modules
Documentation for astrocalc can be found here: http://
astrocalc.readthedocs.org/en/stable
astrocalc.cl_utils
astrocalc.cl_utils (module)
Documentation for astrocalc can be found here: http://astrocalc.readthedocs.org/en/stable
Usage: astrocalc [-c] coordflip <ra> <dec> astrocalc sep <ra1> <dec1> <ra2> <dec2> astrocalc timeflip <datetime>
astrocalc trans <ra> <dec> <north> <east> astrocalc now mjd astrocalc dist (-z | -m) <distVal> [–hc=hVal –
wm=OmegaMatter –wv=OmegaVacuum]
coordflip flip coordinates between decimal degrees and sexegesimal and vice-versa sep calculate the
separation between two locations in the sky. timeflip flip time between UT and MJD. trans translate
a location across the sky (north and east in arcsec) now report current time in various formats dist
convert distance between mpc to z
ra, ra1, ra2 right-ascension in deciaml degrees or sexegesimal format dec, dec1, dec2 declination in
deciaml degrees or sexegesimal format datetime modified julian date (mjd) or universal time (UT).
UT can be formated 20150415113334.343 or “20150415 11:33:34.343” (spaces require quotes)
north, east vector components in arcsec distVal a distance value in Mpc (-mpc) or redshift (-z) hVal
hubble constant value. Default=70 km/s/Mpc OmegaMatter Omega Matter. Default=0.3 OmegaVacuum Omega Vacuum. Default=0.7
-h, --help
show this help message
-m, --mpc
distance in mpc
-z, --redshift
redshift distance
-c, --cartesian
convert to cartesian coordinates
astrocalc.cl_utils.main(arguments=None)
The main function used when ‘‘cl_utils.py‘‘ is run as a single script from the cl, or when installed as a cl
command
18
Chapter 8. Command-Line Tutorial
astrocalc Documentation, Release 0.2.4
Classes
astrocalc.coords.separations
astrocalc.coords.translate
astrocalc.coords.unit_conversion
astrocalc.distances.converter
astrocalc.times.conversions
astrocalc.times.now
The worker class for the separations module
Translate a set of coordinates north and east by distances
given in arcsecs
The worker class for the unit_conversion module
A converter to switch distance between various units of
measurement
The worker class for the conversions module
Report the current time into various formats
astrocalc.coords.separations (class)
class astrocalc.coords.separations(log, ra1, dec1, ra2, dec2, settings=False)
The worker class for the separations module
Key Arguments:
• log – logger
• settings – the settings dictionary
• ra1 – the right-ascension of the first location. Decimal degrees or sexegesimal.
• dec1 – the declination of the first location. Decimal degrees or sexegesimal.
• ra2 – the right-ascension of the second location. Decimal degrees or sexegesimal.
• dec2 – the declination of the second location. Decimal degrees or sexegesimal.
Usage:
Todo
• replace get_angular_separation throughout all code using dryxPython
• replace getAngularSeparationthroughout all code using dryxPython
You can input sexegesimal coordinates,
from astrocalc.coords import separations
calculator = separations(
log=log,
ra1="23:32:23.2324",
dec1="-13:32:45.43553",
ra2="23:32:34.642",
dec2="-12:12:34.9334",
)
angularSeparation, north, east = calculator.get()
print angularSeparation, north, east
# OUT: '4813.39431', '4810.50214', '166.83941'
or decimal degrees,
8.3. Classes
19
astrocalc Documentation, Release 0.2.4
from astrocalc.coords import separations
calculator = separations(
log=log,
ra1=2.3342343,
dec1=89.23244233,
ra2=45.343545345,
dec2=87.3435435
)
angularSeparation, north, east = calculator.get()
print angularSeparation, north, east
# OUT: '7774.4375', '-6800.0358', '4625.7620'
or even a mix of both
from astrocalc.coords import separations
calculator = separations(
log=log,
ra1=352.5342343,
dec1=89.23,
ra2="23:32:34.642",
dec2="89:12:34.9334"
)
angularSeparation, north, east = calculator.get()
print angularSeparation, north, east
# OUT: '78.9', '-73.1', '29.9')
__init__(log, ra1, dec1, ra2, dec2, settings=False)
Methods
__init__(log, ra1, dec1, ra2, dec2[, settings])
get()
Calulate the angular separation between two locations
on the sky
astrocalc.coords.translate (class)
class astrocalc.coords.translate(log, ra, dec, northArcsec, eastArcsec, settings=False)
Translate a set of coordinates north and east by distances given in arcsecs
Key Arguments:
• log – logger
• settings – the settings dictionary. Default False
• ra – ra (decimal or sexegesimal)
• dec – dec (decimal or sexegesimal)
• northArcsec – number of arcsecs to move location to the north
• eastArcsec – number of arcsecs to move location to the east
Todo
20
Chapter 8. Command-Line Tutorial
astrocalc Documentation, Release 0.2.4
•replace shift_coordinates class in all other code
Usage:
To shift a set of coordinates north and east by given distances:
# TRANSLATE COORDINATES ACROSS SKY
from astrocalc.coords import translate
ra, dec = translate(
log=log,
settings=settings,
ra="14.546438",
dec="-45.34232334",
northArcsec=4560,
eastArcsec=+967800
).get()
__init__(log, ra, dec, northArcsec, eastArcsec, settings=False)
Methods
__init__(log, ra, dec, northArcsec, eastArcsec)
get()
translate the coordinates
astrocalc.coords.unit_conversion (class)
class astrocalc.coords.unit_conversion(log, settings=False)
The worker class for the unit_conversion module
Key Arguments:
• log – logger
• settings – the settings dictionary (prob not required)
Usage:
Todo
• add usage info
• create a sublime snippet for usage
• add ra_sexegesimal_to_decimal
usage code
Todo
•@review: when complete, clean unit_conversion class
•@review: when complete add logging
•@review: when complete, decide whether to abstract class to another module
8.3. Classes
21
astrocalc Documentation, Release 0.2.4
__init__(log, settings=False)
Methods
__init__(log[, settings])
dec_decimal_to_sexegesimal(dec[,
iter])
dec_sexegesimal_to_decimal(dec)
delim-
get()
ra_dec_to_cartesian(ra, dec)
ra_decimal_to_sexegesimal(ra[, delimiter])
ra_sexegesimal_to_decimal(ra)
Convert a declination between decimal degrees and sexegesimal.
Convert a declination from sexegesimal format to decimal degrees.
get the unit_conversion object
Convert an RA, DEC coordinate set to x, y, z cartesian
coordinates
Convert a right-ascension between decimal degrees and
sexegesimal.
Convert a right-ascension from sexegesimal format to
decimal degrees.
astrocalc.distances.converter (class)
class astrocalc.distances.converter(log, settings=False)
A converter to switch distance between various units of measurement
Key Arguments:
• log – logger
• settings – the settings dictionary
Usage:
To instantiate a converter object:
from astrocalc.distances import converter
c = converter(log=log)
__init__(log, settings=False)
Methods
__init__(log[, settings])
distance_to_redshift(mpc)
redshift_to_distance(z[, WM, WV, H0])
Convert a distance from MPC to redshift
convert redshift to various distance measurements
astrocalc.times.conversions (class)
class astrocalc.times.conversions(log, settings=False)
The worker class for the conversions module
Key Arguments:
• log – logger
• settings – the settings dictionary
22
Chapter 8. Command-Line Tutorial
astrocalc Documentation, Release 0.2.4
Usage:
Todo
• add usage info
• create a sublime snippet for usage
• add mjd_to_date
• add decimal_day_to_day_hour_min_sec
• add date_to_mjd
• convert all functions in __init__ to modules
usage code
__init__(log, settings=False)
Methods
__init__(log[, settings])
decimal_day_to_day_hour_min_sec(daysFloat) Convert a day from decimal format to hours mins and
sec
get()
get the conversions object
mjd_to_ut_datetime(mjd[, sqlDate, ...])
mjd to ut datetime
ut_datetime_to_mjd(utDatetime)
ut datetime to mjd
astrocalc.times.now (class)
class astrocalc.times.now(log, settings=False)
Report the current time into various formats
Key Arguments:
• log – logger
• settings – the settings dictionary
__init__(log, settings=False)
Methods
__init__(log[, settings])
get_mjd()
Get the current time as an MJD
Functions
astrocalc.luminosity_to_flux
Convert luminosity to a flux
Continued on next page
8.4. Functions
23
astrocalc Documentation, Release 0.2.4
Table 8.10 – continued from previous page
astrocalc.coords.coordinates_to_array
Convert a single value RA, DEC or list of RA and DEC to
numpy arrays
astrocalc.cl_utils.tab_complete
astrocalc.luminosity_to_flux (function)
astrocalc.luminosity_to_flux(lumErg_S, dist_Mpc)
Convert luminosity to a flux
Key Arguments:
• lumErg_S – luminosity in ergs/sec
• dist_Mpc – distance in Mpc
Return:
• fluxErg_cm2_S – flux in ergs/cm2/s
astrocalc.coords.coordinates_to_array (function)
astrocalc.coords.coordinates_to_array(log, ra, dec)
Convert a single value RA, DEC or list of RA and DEC to numpy arrays
Key Arguments:
• ra – list, numpy array or single ra value
• dec –list, numpy array or single dec value
• log – logger
Return:
• raArray – input RAs as a numpy array of decimal degree values
• decArray – input DECs as a numpy array of decimal degree values
Usage:
Todo
add usage info create a sublime snippet for usage
ra, dec = coordinates_to_array(
log=log,
ra=ra,
dec=dec
)
astrocalc.cl_utils.tab_complete (function)
astrocalc.cl_utils.tab_complete(text, state)
24
Chapter 8. Command-Line Tutorial
astrocalc Documentation, Release 0.2.4
Indexes
• Module Index
• Full Index
Todo
• Todolist
8.5. Indexes
25
astrocalc Documentation, Release 0.2.4
26
Chapter 8. Command-Line Tutorial
Python Module Index
a
astrocalc, 17
astrocalc.cl_utils, 18
astrocalc.commonutils, 18
astrocalc.coords, 18
astrocalc.distances, 18
astrocalc.times, 18
27
astrocalc Documentation, Release 0.2.4
28
Python Module Index
Index
Symbols
__init__() (astrocalc.coords.separations method), 20
__init__() (astrocalc.coords.translate method), 21
__init__() (astrocalc.coords.unit_conversion method), 21
__init__() (astrocalc.distances.converter method), 22
__init__() (astrocalc.times.conversions method), 23
__init__() (astrocalc.times.now method), 23
A
astrocalc (module), 17
astrocalc.cl_utils (module), 18
astrocalc.commonutils (module), 18
astrocalc.coords (module), 18
astrocalc.distances (module), 18
astrocalc.times (module), 18
C
conversions (class in astrocalc.times), 22
converter (class in astrocalc.distances), 22
coordinates_to_array() (in module astrocalc.coords), 24
L
luminosity_to_flux() (in module astrocalc), 17, 24
M
main() (in module astrocalc.cl_utils), 18
N
now (class in astrocalc.times), 23
S
separations (class in astrocalc.coords), 19
T
tab_complete() (in module astrocalc.cl_utils), 24
translate (class in astrocalc.coords), 20
U
unit_conversion (class in astrocalc.coords), 21
29