forked from nanograv/PINT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PINT_observatories.py
92 lines (74 loc) · 3.05 KB
/
PINT_observatories.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.14.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# %% [markdown]
# # PINT Observatories
# Basic loading and use of observatories in PINT, including loading custom observatories.
#
# PINT needs to know where telescopes are, what clock corrections are necessary, and
# a bunch of other information in order to correctly process TOAs. In many cases this will be seemlessly handled
# when you load in a set of TOAs. But if you want to look at how/where the observatories are defined or add your own, this is the place to learn.
# %%
# import the library
import pint.observatory
# %% [markdown]
# What observatories are present in PINT? How can we identify them? They have both default names and aliases.
# %%
for name, aliases in pint.observatory.Observatory.names_and_aliases().items():
print(f"Observatory '{name}' is also known as {aliases}")
# %% [markdown]
# Let's get the GBT. When we `print`, we find out some basic info about the observatory name/aliases, location, and and other info present (e.g., where the data are from):
# %%
gbt = pint.observatory.get_observatory("gbt")
print(gbt)
# %% [markdown]
# The observatory also includes info on things like the clock file:
# %%
print(f"GBT clock file is named '{gbt.clock_files}'")
# %% [markdown]
# Some special locations are also present, like the solar system barycenter. You can access explicitly through the `pint.observatory.special_locations` module, but if you just try to get one it will automatically import what is needed
# %%
ssb = pint.observatory.get_observatory("ssb")
# %% [markdown]
# If you want to know where the observatories are defined, you can find that too:
# %%
print(
f"Observatory definitions are in '{pint.observatory.topo_obs.observatories_json}'"
)
# %% [markdown]
# That is the default location, although you can overwrite those definitions by setting `$PINT_CLOCK_OVERRIDE`. You can also define a new observatory andn load it in. We use `JSON` to do this:
# %%
# We want to create a file-like object containing the new definition. So defined as a string, and then use StringIO
import io
notthegbt = r"""
{
"notgbt": {
"tempo_code": "1",
"itoa_code": "GB",
"clock_file": "time_gbt.dat",
"itrf_xyz": [
882589.289,
4924872.368,
3943729.418
],
"origin": "The Robert C. Byrd Green Bank Telescope, except with one coordinate changed.\nThis data was obtained by Joe Swiggum from Ryan Lynch in 2021 September.\n"
}
}
"""
pint.observatory.topo_obs.load_observatories(io.StringIO(notthegbt))
# %% [markdown]
# If we had defined the GBT again, it would have complained unless we used `overwrite=True`. But since this has a new name it's OK. Now let's try to use it:
# %%
notgbt = pint.observatory.get_observatory("notgbt")
print(notgbt)