Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92676255
gZtoGyr
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 22, 16:25
Size
1 KB
Mime Type
text/x-python
Expires
Sun, Nov 24, 16:25 (2 d)
Engine
blob
Format
Raw Data
Handle
22484467
Attached To
rGTOOLS Gtools
gZtoGyr
View Options
#!/usr/bin/env python
from
optparse
import
OptionParser
import
Ptools
as
pt
from
pNbody
import
*
from
pNbody
import
units
from
pNbody
import
ctes
from
pNbody
import
thermodyn
import
string
from
scipy
import
optimize
# DlogA = da / a
#
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parse
=
pt
.
add_units_options
(
parser
)
parser
.
add_option
(
"-Z"
,
action
=
"store"
,
dest
=
"Z"
,
type
=
"float"
,
default
=
0.
,
help
=
"Redshift"
,
metavar
=
" FLOAT"
)
(
options
,
args
)
=
parser
.
parse_args
()
#pt.check_files_number(args)
files
=
args
return
files
,
options
#######################################
# MakePlot
#######################################
def
MakePlot
(
files
,
opt
):
# define local units
unit_params
=
pt
.
do_units_options
(
opt
)
system_of_units
=
units
.
Set_SystemUnits_From_Params
(
unit_params
)
# convert a to Myrs
out_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_cm
,
units
.
Unit_Msol
,
units
.
Unit_Gyr
,
units
.
Unit_K
])
hubbleparam
=
unit_params
[
"HubbleParam"
]
omegalambda
=
unit_params
[
"OmegaLambda"
]
omega0
=
unit_params
[
"Omega0"
]
Hubble
=
ctes
.
HUBBLE
.
into
(
system_of_units
)
pars
=
{
"Hubble"
:
Hubble
,
"HubbleParam"
:
hubbleparam
,
"OmegaLambda"
:
omegalambda
,
"Omega0"
:
omega0
}
funit
=
system_of_units
.
convertionFactorTo
(
out_units
.
UnitTime
)
a
=
cosmo
.
A_z
(
opt
.
Z
)
TMyr
=
cosmo
.
CosmicTime_a
(
a
,
pars
)
/
hubbleparam
*
funit
print
"Z =
%8.6f
a =
%8.6f
=
%10.4f
[Gyr]"
%
(
opt
.
Z
,
a
,
TMyr
)
########################################################################
# MAIN
########################################################################
if
__name__
==
'__main__'
:
files
,
opt
=
parse_options
()
MakePlot
(
files
,
opt
)
Event Timeline
Log In to Comment