Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymagglobal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sec23
korte
pymagglobal
Commits
ed1ed87b
Commit
ed1ed87b
authored
4 years ago
by
Stefan Mauerberger
Browse files
Options
Downloads
Patches
Plain Diff
Begun documenting pymagglobal.commands
parent
1f526369
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Docs
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pymagglobal/commands.py
+31
-10
31 additions, 10 deletions
pymagglobal/commands.py
with
31 additions
and
10 deletions
pymagglobal/commands.py
+
31
−
10
View file @
ed1ed87b
...
...
@@ -40,25 +40,28 @@ from . import utils
class
OutOfRangeWarning
(
Warning
):
'''
j
ust to give the warning a meaningful name
'''
'''
J
ust to give the warning a meaningful name
.
'''
pass
def
valid_epoch
(
args
):
'''
c
heck whether the epoch given via the command line is in the range of
the model
'''
C
heck whether the epoch given via the command line is in the range of
the model
.
Parameters
----------
args : object
the object returned by ArgumentParser.parse_args()
An object that provides access to attributes `input`, `longerm` and
`epoch` e.g. the SimpleNamspace object returned by
ArgumentParser.parse_args().
Returns
-------
float
t
he epoch in yrs
T
he epoch in y
ea
rs
.
'''
# get the range of the model from the model file
# XXX Duplication of code see file2splines()
with
open
(
args
.
input
,
'
r
'
)
as
fh
:
t_min
,
t_max
=
map
(
float
,
fh
.
readline
().
split
()[
0
:
2
])
if
args
.
longterm
:
...
...
@@ -73,14 +76,20 @@ def valid_epoch(args):
def
args2times
(
args
):
'''
r
ead the range of the model and create a linear array to evaluate it.
m
ake use of the command line arguments --every and --res
'''
R
ead the range of the model and create a linear array to evaluate it.
M
ake use of the command line arguments
`
--every
`
and
`
--res
`.
Parameters
----------
args : object
the object returned by ArgumentParser.parse_args()
The SimpleNamespace object returned by ArgumentParser.parse_args().
Returns
-------
times : ndarray
An equally spaced array in years.
'''
# XXX Duplication of code see file2splines()
with
open
(
args
.
input
,
'
r
'
)
as
fh
:
t_min
,
t_max
=
map
(
float
,
fh
.
readline
().
split
()[
0
:
2
])
if
args
.
begin
is
not
None
:
...
...
@@ -104,8 +113,20 @@ def args2times(args):
def
yr2lt
(
times
):
'''
translate times given as years to the format / age often used
for longterm models
'''
'''
Translate times given in years AD into kilo-years `before present
<https://en.wikipedia.org/wiki/Before_Present>`_ often used for
longterm models.
Parameters
----------
times: float or int
Years AD.
Returns
-------
float
Kilo years before present (backward counting from 1/1/1950).
'''
return
-
(
times
-
1950
)
/
1000
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment