Skip to content

Commit

Permalink
Merge e4ca9e0 into 71a69a6
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Jul 9, 2017
2 parents 71a69a6 + e4ca9e0 commit 7c763f4
Show file tree
Hide file tree
Showing 34 changed files with 85 additions and 184 deletions.
50 changes: 7 additions & 43 deletions src/adstring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ Arguments of this function are:
The function can be called in different ways:
* Two numeric arguments: first is `ra`, the second is `dec`.
* A 2-tuple `(ra, dec)`.
* One 2-element numeric array: `[ra, dec]`. A single string is returned.
* An iterable (array, tuple) of two elements: `(ra, dec)`.
* One numeric argument: it is assumed only `dec` is provided.
* Two numeric arrays of the same length: `ra` and `dec` arrays. An array of
strings is returned.
* An array of 2-tuples `(ra, dec)`.
Optional keywords affecting the output format are always available:
Expand All @@ -64,11 +60,8 @@ Optional keywords affecting the output format are always available:
### Output ###
The function returns one string if the function was called with scalar `ra` and
`dec` (or only `dec`) or a 2-element array `[ra, dec]`. If instead it was
feeded with arrays of `ra` and `dec`, an array of strings will be returned. The
format of strings can be specified with `precision` and `truncate` keywords, see
above.
The function returns one string. The format of strings can be specified with `precision`
and `truncate` keywords, see above.
### Example ###
Expand All @@ -78,8 +71,8 @@ julia> using AstroLib
julia> adstring(30.4, -1.23, truncate=true)
" 02 01 35.9 -01 13 48"
julia> adstring([30.4, -15.63], [-1.23, 48.41], precision=1)
2-element Array{AbstractString,1}:
julia> adstring.([30.4, -15.63], [-1.23, 48.41], precision=1)
2-element Array{String,1}:
" 02 01 36.00 -01 13 48.0"
" 22 57 28.80 +48 24 36.0"
```
Expand Down Expand Up @@ -111,39 +104,10 @@ adstring(ra::Real, dec::Real;
adstring(promote(float(ra), float(dec))...,
precision=precision, truncate=truncate)

adstring(radec::Tuple{Real, Real};
precision::Int=0, truncate::Bool=false) =
adstring(radec..., precision=precision, truncate=truncate)
adstring(radec; precision::Int=0, truncate::Bool=false) =
adstring(radec..., precision=precision, truncate=truncate)

# When printing only declination, IDL implementation defaults "precision" to 1
# instead of 0.
adstring(dec::Real; precision::Int=1, truncate::Bool=false) =
adstring(NaN, dec, precision=precision, truncate=truncate)

function adstring{T<:Real}(radec::AbstractArray{T};
precision::Int=0, truncate::Bool=false)
@assert length(radec) == 2 "provide a 2-element [ra, dec] array"
return adstring(radec[1], radec[2], precision=precision, truncate=truncate)
end

function adstring{R<:Real, D<:Real}(ra::AbstractArray{R},
dec::AbstractArray{D};
precision::Int=0, truncate::Bool=false)
@assert length(ra) == length(dec) "ra and dec arrays should be of the same length"
result = similar(ra, AbstractString)
for i in eachindex(ra)
result[i] = adstring(ra[i], dec[i],
precision=precision, truncate=truncate)
end
return result
end

function adstring{N<:Real}(radec::AbstractArray{Tuple{N, N}};
precision::Int=0, truncate::Bool=false)
result = similar(radec, AbstractString)
for i in eachindex(radec)
result[i] = adstring(radec[i]...,
precision=precision, truncate=truncate)
end
return result
end
13 changes: 5 additions & 8 deletions src/airtovac.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@ Converts air wavelengths to vacuum wavelengths.
### Explanation ###
Wavelengths are corrected for the index of refraction of air under standard
conditions. Wavelength values below \$2000 Å\$ will not be altered. Uses
relation of Ciddor (1996).
Wavelengths are corrected for the index of refraction of air under standard conditions.
Wavelength values below \$2000 Å\$ will *not* be altered, take care within \$[1 Å, 2000
Å]\$. Uses relation of Ciddor (1996).
### Arguments ###
* `wave_air`: can be either a scalar or an array of numbers. Wavelengths are
corrected for the index of refraction of air under standard conditions.
Wavelength values below \$2000 Å\$ will *not* be altered, take care within \$[1
Å, 2000 Å]\$.
* `wave_air`: the wavelength in air.
### Output ###
Vacuum wavelength in angstroms, same number of elements as `wave_air`.
Vacuum wavelength in angstroms.
### Method ###
Expand Down
15 changes: 7 additions & 8 deletions src/calz_unred.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2016 Mosè Giordano.

function calz_unred(wave::T, flux::T, ebv::T, r_v::T) where {T<:AbstractFloat}
x = 10000.0/wave # Wavelength in inverse microns
x = 10000 / wave # Wavelength in inverse microns
if 6300 <= wave <= 22000
klam = 2.659*(-1.857 + 1.040*x) + r_v
elseif 912 <= wave < 6300
Expand Down Expand Up @@ -30,22 +30,21 @@ between \$0.12\$ and \$0.0912\$ microns.)
### Arguments ###
* `wave`: wavelength vector (Angstroms)
* `flux`: calibrated flux vector, same number of elements as `wave`.
* `ebv`: color excess E(B-V), scalar. If a negative `ebv` is supplied, then
* `wave`: wavelength (Angstroms)
* `flux`: calibrated flux.
* `ebv`: color excess E(B-V). If a negative `ebv` is supplied, then
fluxes will be reddened rather than deredenned. Note that the supplied color
excess should be that derived for the stellar continuum, EBV(stars), which is
related to the reddening derived from the gas, EBV(gas), via the Balmer
decrement by EBV(stars) = 0.44*EBV(gas).
* `r_v` (optional): scalar ratio of total to selective extinction, default is
* `r_v` (optional): ratio of total to selective extinction, default is
4.05. Calzetti et al. (2000) estimate ``r_v = 4.05 \\pm 0.80`` from optical-IR
observations of 4 starbursts.
### Output ###
Unreddened flux vector, same units and number of elements as `flux`. Flux
values will be left unchanged outside valid domain (\$0.0912\$ - \$2.2\$
microns).
Unreddened flux, same units as `flux`. Flux values will be left unchanged outside valid
domain (\$0.0912\$ - \$2.2\$ microns).
### Example ###
Expand Down
17 changes: 7 additions & 10 deletions src/ct2lst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,25 @@ Convert from Local Civil Time to Local Mean Sidereal Time.
The function can be called in two different ways. The only argument common to
both methods is `longitude`:
* `longitude`: the longitude in degrees (east of Greenwich) of the place for
which the local sidereal time is desired, scalar. The Greenwich mean sidereal
time (GMST) can be found by setting longitude = `0`.
* `longitude`: the longitude in degrees (east of Greenwich) of the place for which the local
sidereal time is desired. The Greenwich mean sidereal time (GMST) can be found by setting
longitude = `0`.
The civil date to be converted to mean sidereal time can be specified either by
providing the Julian days:
* `jd`: this is number of Julian days for the date to be converted. It can be a
scalar or an array.
* `jd`: this is number of Julian days for the date to be converted.
or the time zone and the date:
* `tz`: the time zone of the site in hours, positive East of the
Greenwich meridian (ahead of GMT). Use this parameter to easily
account for Daylight Savings time (e.g. -4=EDT, -5 = EST/CDT), scalar.
* `date`: this is the local civil time with type `DateTime`. It can
be a scalar or an array.
account for Daylight Savings time (e.g. -4=EDT, -5 = EST/CDT).
* `date`: this is the local civil time with type `DateTime`.
### Output ###
The local sidereal time for the date/time specified in hours. This is a scalar
or an array of the same length as `jd` or `date`.
The local sidereal time for the date/time specified in hours.
### Method ###
Expand Down
2 changes: 1 addition & 1 deletion src/daycnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ returns the corresponding proleptic Gregorian Calendar date.
### Argument ###
* `julian_days`: Julian days number, scalar or array.
* `julian_days`: Julian days number.
### Output ###
Expand Down
8 changes: 4 additions & 4 deletions src/flux2mag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ This is the reverse of `mag2flux`.
### Arguments ###
* `flux`: the flux to be converted in magnitude, expressed in
erg/(s cm² Å). It can be either a scalar or an array.
* `zero_point`: scalar giving the zero point level of the magnitude. If not
erg/(s cm² Å).
* `zero_point`: the zero point level of the magnitude. If not
supplied then defaults to 21.1 (Code et al 1976). Ignored if the `ABwave`
keyword is supplied
* `ABwave` (optional numeric keyword): wavelength scalar or vector in Angstroms.
* `ABwave` (optional numeric keyword): wavelength in Angstroms.
If supplied, then returns Oke AB magnitudes (Oke & Gunn 1983, ApJ, 266, 713;
http://adsabs.harvard.edu/abs/1983ApJ...266..713O).
### Output ###
The magnitude. It is of the same type, scalar or array, as `flux`.
The magnitude.
If the `ABwave` keyword is set then magnitude is given by the expression
Expand Down
7 changes: 0 additions & 7 deletions src/gcirc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ julia> gcirc(0, 120, -43, 175, +22)
### Notes ###
* If `ra1`, `dec1` are scalars, and `ra2`, `dec2` are vectors, then the output
is a vector giving the distance of each element of `ra2`, `dec2` to `ra1`,
`dec1`. Similarly, if `ra1`,`de1` are vectors, and `ra2`,` dec2` are scalars,
then the output is a vector giving the distance of each element of `ra1`,
`dec1` to `ra2`, `dec2`. If both `ra1`, `dec1` and `ra2`, `dec2` are vectors
then the output is a vector giving the distance of each element of `ra1`,
`dec1` to the corresponding element of `ra2`, `dec2`.
* The function `sphdist` provides an alternate method of computing a spherical
distance.
* The Haversine formula can give rounding errors for antipodal points.
Expand Down
9 changes: 4 additions & 5 deletions src/get_date.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ header.
### Argument ###
* `date` (optional): the date in UTC standard. If omitted, defaults to the
current UTC time. It can be either a single date or an array of dates. Each
element can be either a `DateTime` type or anything that can be converted to
that type. In the case of vectorial input, each element is considered as a
date, so you cannot provide a date by parts.
* `date` (optional): the date in UTC standard. If omitted, defaults to the current UTC
time. Each element can be either a `DateTime` type or anything that can be converted to
that type. In the case of vectorial input, each element is considered as a date, so you
cannot provide a date by parts.
* `old` (optional boolean keyword): see below.
* `timetag` (optional boolean keyword): see below.
Expand Down
7 changes: 3 additions & 4 deletions src/helio_jd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ IDL code available at http://astroutils.astronomy.ohio-state.edu/time/
### Arguments ###
* `date`: reduced Julian date (= JD - 2400000), it can be either a scalar or
vector. You can use `juldate()` to calculate the reduced Julian date.
* `ra` and `dec`: scalars giving right ascension and declination in degrees.
Default equinox is J2000.
* `date`: reduced Julian date (= JD - 2400000). You can use `juldate()` to calculate the
reduced Julian date.
* `ra` and `dec`: right ascension and declination in degrees. Default equinox is J2000.
* `B1950` (optional boolean keyword): if set to `true`, then input coordinates
are assumed to be in equinox B1950 coordinates. Default is `false`.
* `diff` (optional boolean keyword): if set to `true`, the function returns the
Expand Down
7 changes: 3 additions & 4 deletions src/helio_rv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ binary star at a given heliocentric date given its orbit.
### Arguments ###
* `jd`: time of observation, as number of Julian days. It can be either a
scalar or an array.
* `jd`: time of observation, as number of Julian days.
* `T`: time of periastron passage (max. +ve velocity for circular orbits), same
time system as `jd`
* `P`: the orbital period in same units as `jd`
Expand All @@ -35,8 +34,8 @@ binary star at a given heliocentric date given its orbit.
### Output ###
The predicted heliocentric radial velocity in the same units as Gamma for the
date(s) specified by `jd`. It is a scalar or an array depending on the type
of`jd`.
date(s) specified by `jd`.
### Example ###
(1) What was the heliocentric radial velocity of the primary component of HU Tau
Expand Down
11 changes: 5 additions & 6 deletions src/ismeuv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ The EUV optical depth is computed from the photoionization of hydrogen and heliu
### Arguments ###
* `wave`: scalar of wavelength value (in Angstroms). Useful range is 40 - 912 A;
* `wave`: wavelength value (in Angstroms). Useful range is 40 - 912 A;
at shorter wavelength metal opacity should be considered, at longer wavelengths
there is no photoionization.
* `hcol`: scalar specifying interstellar hydrogen column density in cm-2.
* `he1col` (optional): scalar specifying neutral helium column density in cm-2.
* `hcol`: interstellar hydrogen column density in cm-2.
* `he1col` (optional): neutral helium column density in cm-2.
Default is 0.1*hcol (10% of hydrogen column)
* `he2col` (optional): scalar specifying ionized helium column density in cm-2
* `he2col` (optional): ionized helium column density in cm-2
Default is 0.
* `fano` (optional boolean keyword): If this keyword is true, then the 4 strongest
auto-ionizing resonances of He I are included. The shape of these resonances
Expand All @@ -71,8 +71,7 @@ The EUV optical depth is computed from the photoionization of hydrogen and heliu
### Output ###
* `tau`: Vector giving resulting optical depth, same number of elements as wave,
non-negative values.
* `tau`: Vector giving resulting optical depth, non-negative values.
### Example ###
Expand Down
6 changes: 2 additions & 4 deletions src/jdcnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ of Julian calendar days since epoch `-4713-11-24T12:00:00`.
### Argument ###
* `date`: date in proleptic Gregorian Calendar. Can be either a single date or
an array of dates. Each element can be either a `DateTime` type or anything
that can be converted directly to `DateTime`. In the case of vectorial input,
each element is considered as a date, so you cannot provide a date by parts.
* `date`: date in proleptic Gregorian Calendar. Each element can be either a `DateTime` or
anything that can be converted directly to `DateTime`.
### Output ###
Expand Down
9 changes: 3 additions & 6 deletions src/juldate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ days since epoch `1858-11-16T12:00:00` (Reduced Julian Days = Julian Days -
### Argument ###
* `date`: date in Julian Calendar, UTC standard. It can be either e single date
or an array of dates. Each element can be given in `DateTime` type or
anything that can be converted to that type. In the case of vectorial input,
each element is considered as a date, so you cannot provide a date by parts.
* `date`: date in Julian Calendar, UTC standard. Each element can be given in `DateTime`
type or anything that can be converted to that type.
### Output ###
The number of Reduced Julian Days is returned. If `date` is an array, an array
of the same length as `date` is returned.
The number of Reduced Julian Days is returned.
### Example ###
Expand Down
6 changes: 2 additions & 4 deletions src/kepler_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ given and one wants to find the eccentric anomaly \$E(t)\$ at a specific time
### Arguments ###
* `M`: mean anomaly. This can be either a scalar or an array
* `M`: mean anomaly.
* `e`: eccentricity, in the elliptic motion regime (\$0 \\leq e \\leq 1\$)
### Output ###
The eccentric anomaly \$E\$, restricted to the range \$[-\\pi, \\pi]\$. If an
array of mean anomalies is provided in input, an array of the same length as `M`
is returned.
The eccentric anomaly \$E\$, restricted to the range \$[-\\pi, \\pi]\$.
### Method ###
Expand Down
10 changes: 4 additions & 6 deletions src/lsf_rotate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ across the disk.
### Arguments ###
* `delta_v`: numeric scalar giving the step increment (in km/s) in the output
rotation kernel
* `delta_v`: the step increment (in km/s) in the output rotation kernel
* `v_sin_i`: the rotational velocity projected along the line of sight (km/s)
* `epsilon` (optional numeric argument): numeric scalar giving the
limb-darkening coefficient, default = 0.6 which is typical for photospheric
lines. The specific intensity \$I\$ at any angle \$\\theta\$ from the
specific intensity \$I_{\\text{cen}}\$ at the center of the disk is given by:
* `epsilon` (optional numeric argument): the limb-darkening coefficient, default = 0.6 which
is typical for photospheric lines. The specific intensity \$I\$ at any angle \$\\theta\$
from the specific intensity \$I_{\\text{cen}}\$ at the center of the disk is given by:
`` I = I_{\\text{cen}}\\cdot(1 - \\varepsilon\\cdot(1 - \\cos(\\theta)))``
Expand Down
15 changes: 6 additions & 9 deletions src/mag2flux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@ This is the reverse of `flux2mag`.
### Arguments ###
* `mag`: the magnitude to be converted in flux. It can be either a scalar or an
array.
* `zero_point`: scalar giving the zero point level of the magnitude. If not
supplied then defaults to 21.1 (Code et al 1976). Ignored if the `ABwave`
keyword is supplied
* `ABwave` (optional numeric keyword): wavelength, scalar or array, in
Angstroms. If supplied, then the input `mag` is assumed to contain Oke AB
magnitudes (Oke & Gunn 1983, ApJ, 266, 713;
* `mag`: the magnitude to be converted in flux.
* `zero_point`: the zero point level of the magnitude. If not supplied then defaults to
21.1 (Code et al 1976). Ignored if the `ABwave` keyword is supplied
* `ABwave` (optional numeric keyword): wavelength, in Angstroms. If supplied, then the
input `mag` is assumed to contain Oke AB magnitudes (Oke & Gunn 1983, ApJ, 266, 713;
http://adsabs.harvard.edu/abs/1983ApJ...266..713O).
### Output ###
The flux. It is of the same type, scalar or array, as `mag`.
The flux.
If the `ABwave` keyword is set, then the flux is given by the expression
Expand Down

0 comments on commit 7c763f4

Please sign in to comment.