garib 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- garib-0.0.1/GARIB/__init__.py +0 -0
- garib-0.0.1/GARIB/garib.py +236 -0
- garib-0.0.1/GARIB/h5py_file_open.py +38 -0
- garib-0.0.1/GARIB/testing.py +36 -0
- garib-0.0.1/PKG-INFO +12 -0
- garib-0.0.1/README.md +0 -0
- garib-0.0.1/garib.egg-info/PKG-INFO +12 -0
- garib-0.0.1/garib.egg-info/SOURCES.txt +11 -0
- garib-0.0.1/garib.egg-info/dependency_links.txt +1 -0
- garib-0.0.1/garib.egg-info/requires.txt +5 -0
- garib-0.0.1/garib.egg-info/top_level.txt +1 -0
- garib-0.0.1/pyproject.toml +22 -0
- garib-0.0.1/setup.cfg +4 -0
|
File without changes
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import astropy.units as u
|
|
3
|
+
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
|
|
4
|
+
import healpy as hp
|
|
5
|
+
import h5py
|
|
6
|
+
from scipy.interpolate import RegularGridInterpolator
|
|
7
|
+
from astropy.time import Time
|
|
8
|
+
from astropy.time import Time, TimeDelta
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
phi_res = 1.0
|
|
12
|
+
theta_res = 1.0
|
|
13
|
+
theta_array = np.arange(-90, 90 + theta_res, theta_res)
|
|
14
|
+
theta_array = np.round(theta_array, 2)
|
|
15
|
+
phi_array = np.arange(0, 360, phi_res)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def find_nearest(array, value):
|
|
19
|
+
array = np.asarray(array)
|
|
20
|
+
idx = (np.abs(array - value)).argmin()
|
|
21
|
+
return array[idx]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def inside_rectangle_np(points, rect_bottom_left, rect_top_right, include_boundary=True):
|
|
25
|
+
x1, y1 = rect_bottom_left
|
|
26
|
+
x2, y2 = rect_top_right
|
|
27
|
+
xmin, xmax = min(x1, x2), max(x1, x2)
|
|
28
|
+
ymin, ymax = min(y1, y2), max(y1, y2)
|
|
29
|
+
|
|
30
|
+
px, py = points[:, 0], points[:, 1]
|
|
31
|
+
if include_boundary:
|
|
32
|
+
mask = (xmin <= px) & (px <= xmax) & (ymin <= py) & (py <= ymax)
|
|
33
|
+
else:
|
|
34
|
+
mask = (xmin < px) & (px < xmax) & (ymin < py) & (py < ymax)
|
|
35
|
+
return mask
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class GalaxyElimination(object):
|
|
39
|
+
def __init__(self, **kwargs):
|
|
40
|
+
|
|
41
|
+
for key, value in kwargs.items():
|
|
42
|
+
setattr(self, key, value)
|
|
43
|
+
|
|
44
|
+
self.read_beam()
|
|
45
|
+
self.coordinate_generation()
|
|
46
|
+
self.set_location()
|
|
47
|
+
self.fixed_radius()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def read_beam(self):
|
|
52
|
+
""" Reading the beam-file:
|
|
53
|
+
|
|
54
|
+
Reads the .h5 file provided
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
file (.h5) : An output file of the beam convolved with sky
|
|
58
|
+
nside (int) : Resolution of the sky-map
|
|
59
|
+
chosen_frequency (float) : Frequency for the beam
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
beam_val (func) : Interpolated beam function
|
|
64
|
+
frequency (array) : Reads frequency from the file
|
|
65
|
+
lst (array) : Reads LST from the file
|
|
66
|
+
tsky (2D array) : 2D array of number of pixels and frequencies
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
f = h5py.File(self.file, 'r')
|
|
71
|
+
beam_3D = f['ancillary_prod']['beam'][()]
|
|
72
|
+
freq = f['index_map']['frequency'][()]
|
|
73
|
+
LST = f['index_map']['LST'][()]
|
|
74
|
+
chosen_freq_idx = np.where(freq==self.chosen_frequency)[0][0]
|
|
75
|
+
beam_val = RegularGridInterpolator((theta_array, phi_array), beam_3D[chosen_freq_idx])
|
|
76
|
+
npix = hp.nside2npix(self.nside)
|
|
77
|
+
tsky = np.zeros((npix, len(freq)))
|
|
78
|
+
dt = TimeDelta(np.linspace(0.,24.*3600, 500), format='sec')
|
|
79
|
+
obstimes = Time('2019-4-12 23:00:00') + dt
|
|
80
|
+
|
|
81
|
+
self.beam_val = beam_val
|
|
82
|
+
self.frequency = freq
|
|
83
|
+
self.lst = LST
|
|
84
|
+
self.tsky = tsky
|
|
85
|
+
self.time = obstimes
|
|
86
|
+
|
|
87
|
+
def coordinate_generation(self):
|
|
88
|
+
""" Generation of galactic coordinates for a given resolution
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
nside (int) : Resolution of the sky-map
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
|
|
96
|
+
l-coordinate (array): Galactic longitude
|
|
97
|
+
b-coordinate (array): Galactic latitude
|
|
98
|
+
|
|
99
|
+
"""
|
|
100
|
+
npix = hp.nside2npix(self.nside)
|
|
101
|
+
pixels = np.arange(npix)
|
|
102
|
+
theta, phi = hp.pix2ang(self.nside, pixels, nest=True)
|
|
103
|
+
|
|
104
|
+
ll_coordinate = phi
|
|
105
|
+
bb_coordinate = np.pi/2. - theta
|
|
106
|
+
|
|
107
|
+
self.ll_coordinate = ll_coordinate
|
|
108
|
+
self.bb_coordinate = bb_coordinate
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def set_location(self):
|
|
112
|
+
"""Choosing location on Earth
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
site latitude [degrees] (float) : Latitude of site location
|
|
116
|
+
site longitude [degrees] (float) : Longitude of site location
|
|
117
|
+
height [meters] (float) : Elevation above the sea level
|
|
118
|
+
|
|
119
|
+
ll_coordinate [degrees] : latitude co-ordinate array for the healpy map
|
|
120
|
+
bb_coordinate [degrees] : longitude co-ordinate array for the healpy map
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
location : Location information for the particular location on Earth
|
|
124
|
+
gc : Galactic coordinates for the galactic map
|
|
125
|
+
|
|
126
|
+
"""
|
|
127
|
+
location = EarthLocation(lat=self.site_latitude*u.deg, lon=self.site_longitude*u.deg, height=self.elevation*u.m)
|
|
128
|
+
gc = SkyCoord(l=self.ll_coordinate*u.radian, b=self.bb_coordinate*u.radian,\
|
|
129
|
+
frame='galactic')
|
|
130
|
+
self.gc = gc
|
|
131
|
+
self.location = location
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def fixed_radius(self):
|
|
136
|
+
""" Fixing radius of the beam
|
|
137
|
+
|
|
138
|
+
Computes the radius of the beam for an observation time where the beam lies near the center of the galactic plane
|
|
139
|
+
|
|
140
|
+
"""
|
|
141
|
+
trans_local = self.gc.transform_to(AltAz(obstime=self.time[int(len(self.lst)/2)], location=self.location))
|
|
142
|
+
az, alt = trans_local.az.degree, trans_local.alt.degree
|
|
143
|
+
beam_gen = np.zeros_like(self.tsky)
|
|
144
|
+
|
|
145
|
+
rogue_phi = []
|
|
146
|
+
|
|
147
|
+
for iangle, (alt_value, az_value) in enumerate(zip(alt,az)):
|
|
148
|
+
if az_value > phi_array.max():
|
|
149
|
+
rogue_phi.append(az_value)
|
|
150
|
+
az_value = 360 - az_value
|
|
151
|
+
beam_gen[iangle,0] = self.beam_val([alt_value, az_value])[0]
|
|
152
|
+
|
|
153
|
+
hf_bm = find_nearest(beam_gen[:,0], 0.5)
|
|
154
|
+
idx_hf = np.where(beam_gen[:,0] == hf_bm)
|
|
155
|
+
|
|
156
|
+
idx = np.where(beam_gen[:,0] == max(beam_gen[:,0]))
|
|
157
|
+
theta_c, phi_c = hp.pix2ang(self.nside, idx[0][0], nest=True)
|
|
158
|
+
|
|
159
|
+
theta_hf, phi_hf = hp.pix2ang(self.nside, idx_hf[0][0], nest=True)
|
|
160
|
+
|
|
161
|
+
vec_c = hp.ang2vec(theta_c, phi_c)
|
|
162
|
+
vec_hf = hp.ang2vec(theta_hf, phi_hf)
|
|
163
|
+
radius = np.arccos(np.clip(np.dot(vec_c, vec_hf), -1.0, 1.0))
|
|
164
|
+
|
|
165
|
+
self.radius = radius
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def time_elimination(self):
|
|
169
|
+
"""
|
|
170
|
+
Elimination of observation times with Galaxy
|
|
171
|
+
|
|
172
|
+
This function eliminates the times of observations where the beam crosses the galaxy.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
Obstimes (list) : Times of observation
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
"""
|
|
179
|
+
masked_timestamps = []
|
|
180
|
+
good_timestamps = []
|
|
181
|
+
for ii in range(len(self.time)):
|
|
182
|
+
trans_local = self.gc.transform_to(AltAz(obstime=self.time[ii], location=self.location))
|
|
183
|
+
az, alt = trans_local.az.degree, trans_local.alt.degree
|
|
184
|
+
ind_below_horizon = alt < 0
|
|
185
|
+
beam_gen = np.zeros_like(self.tsky)
|
|
186
|
+
|
|
187
|
+
rogue_phi = []
|
|
188
|
+
|
|
189
|
+
for iangle, (alt_value, az_value) in enumerate(zip(alt,az)):
|
|
190
|
+
if az_value > phi_array.max():
|
|
191
|
+
rogue_phi.append(az_value)
|
|
192
|
+
az_value = 360 - az_value
|
|
193
|
+
beam_gen[iangle,0] = self.beam_val([alt_value, az_value])[0]
|
|
194
|
+
|
|
195
|
+
hf_bm = find_nearest(beam_gen[:,0], 0.5)
|
|
196
|
+
idx_hf = np.where(beam_gen[:,0] == hf_bm)
|
|
197
|
+
|
|
198
|
+
idx = np.where(beam_gen[:,0] == max(beam_gen[:,0]))
|
|
199
|
+
theta_c, phi_c = hp.pix2ang(self.nside, idx[0][0], nest=True)
|
|
200
|
+
|
|
201
|
+
radius = self.radius
|
|
202
|
+
npts = 1000
|
|
203
|
+
phi = np.linspace(0, 2*np.pi, npts)
|
|
204
|
+
|
|
205
|
+
theta_ring = np.arccos(np.cos(radius) * np.cos(theta_c) +
|
|
206
|
+
np.sin(radius) * np.sin(theta_c) * np.cos(phi))
|
|
207
|
+
phi_ring = phi_c + np.arctan2(np.sin(phi) * np.sin(radius) * np.sin(theta_c),
|
|
208
|
+
np.cos(radius) - np.cos(theta_ring) * np.cos(theta_c))
|
|
209
|
+
|
|
210
|
+
lon = np.degrees(phi_ring)
|
|
211
|
+
lat = 90 - np.degrees(theta_ring)
|
|
212
|
+
|
|
213
|
+
l = self.l
|
|
214
|
+
b = self.b
|
|
215
|
+
|
|
216
|
+
rbl = (-l,-b)
|
|
217
|
+
rtr = (+l,+b)
|
|
218
|
+
|
|
219
|
+
lb = np.stack((lon,lat), axis=1)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
if inside_rectangle_np((lb), rbl, rtr).any() == True:
|
|
223
|
+
observing_time = Time(self.time[ii], scale='utc', location=self.location)
|
|
224
|
+
LST = observing_time.sidereal_time('mean').value
|
|
225
|
+
masked_timestamps.append(LST)
|
|
226
|
+
|
|
227
|
+
else:
|
|
228
|
+
observing_time = Time(self.time[ii], scale='utc', location=self.location)
|
|
229
|
+
LST = observing_time.sidereal_time('mean').value
|
|
230
|
+
good_timestamps.append(LST)
|
|
231
|
+
|
|
232
|
+
msk_tstps = np.array(masked_timestamps) # Has Galaxy Coverage
|
|
233
|
+
gd_tstps = np.array(good_timestamps) # Galaxy is eliminated
|
|
234
|
+
|
|
235
|
+
return np.savetxt('badtimes.txt', msk_tstps)
|
|
236
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import h5py
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import numpy as np
|
|
4
|
+
from matplotlib import cm, ticker
|
|
5
|
+
|
|
6
|
+
f = h5py.File('SINESQ_500times_EARTH_jun26.h5','r')
|
|
7
|
+
|
|
8
|
+
LST = f['index_map']['LST'][()]
|
|
9
|
+
freq = f['index_map']['frequency'][()]
|
|
10
|
+
ind_sorted = np.argsort(LST)
|
|
11
|
+
lst = LST[ind_sorted]
|
|
12
|
+
|
|
13
|
+
T = f['T_A'][()][ind_sorted,:]
|
|
14
|
+
T = np.log10(T)
|
|
15
|
+
|
|
16
|
+
gd_times = np.loadtxt('badtimes.txt')
|
|
17
|
+
index = []
|
|
18
|
+
for i in range(len(gd_times)):
|
|
19
|
+
ind = np.where(gd_times[i] == lst)[0][0]
|
|
20
|
+
index.append(ind)
|
|
21
|
+
|
|
22
|
+
ind_arr = np.array(index)
|
|
23
|
+
|
|
24
|
+
T[ind_arr,:] = np.nan
|
|
25
|
+
|
|
26
|
+
#### Create meshgrid of frequencies and LST value
|
|
27
|
+
plt.figure(figsize=(10,6))
|
|
28
|
+
freq_mesh1, lst_mesh1 = np.meshgrid(freq, lst)
|
|
29
|
+
|
|
30
|
+
plt.imshow(T, extent=(freq[0], freq[-1], lst[0], lst[-1]), aspect='auto', origin='lower',
|
|
31
|
+
interpolation='none', cmap='viridis', vmin=np.nanmin(T), vmax=np.nanmax(T))
|
|
32
|
+
|
|
33
|
+
plt.xlabel('Frequency (MHz)', fontsize=15)
|
|
34
|
+
plt.ylabel('LST (hours)', fontsize=15)
|
|
35
|
+
plt.xticks(fontsize=13)
|
|
36
|
+
plt.yticks(fontsize=13)
|
|
37
|
+
cbar = plt.colorbar()
|
|
38
|
+
cbar.ax.tick_params(labelsize=12)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import astropy.units as u
|
|
3
|
+
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
|
|
4
|
+
import healpy as hp
|
|
5
|
+
import h5py
|
|
6
|
+
from scipy.interpolate import RegularGridInterpolator
|
|
7
|
+
from astropy.time import Time, TimeDelta
|
|
8
|
+
from garib import GalaxyElimination
|
|
9
|
+
|
|
10
|
+
file = "SINESQ_500times_EARTH_jun26.h5"
|
|
11
|
+
|
|
12
|
+
SITE_LATITUDE = 32.81444444 #/* +32.77944444 deg for Hanle */
|
|
13
|
+
SITE_LONGITUDE = 78.85555556 #/* 78.96416667 deg for Hanle */
|
|
14
|
+
ELEVATION = 4500
|
|
15
|
+
|
|
16
|
+
dt = TimeDelta(np.linspace(0.,24.*3600, 500), format='sec') #Will NOT take ~5 min
|
|
17
|
+
obstimes = Time('2019-4-12 23:00:00') + dt
|
|
18
|
+
|
|
19
|
+
chosen_frequency = 65
|
|
20
|
+
nside = 16
|
|
21
|
+
lmax = 45
|
|
22
|
+
bmax = 10
|
|
23
|
+
|
|
24
|
+
param_obs = {'file': file,\
|
|
25
|
+
'chosen_frequency': chosen_frequency,\
|
|
26
|
+
'site_latitude': SITE_LATITUDE,\
|
|
27
|
+
'site_longitude': SITE_LONGITUDE,\
|
|
28
|
+
'elevation': ELEVATION,\
|
|
29
|
+
'nside': nside,\
|
|
30
|
+
'l':lmax,\
|
|
31
|
+
'b':bmax}
|
|
32
|
+
|
|
33
|
+
# Galaxy Avoidance for RadIo antenna Beams: GARIB
|
|
34
|
+
|
|
35
|
+
GE = GalaxyElimination(**param_obs)
|
|
36
|
+
GE.time_elimination()
|
garib-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: garib
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: This packages eliminates the observation times when the beam of the radio antenna crosses the a rectangular region in the sky.
|
|
5
|
+
Author-email: "Abhijeet S. Patil" <abhijeet@rrimail.rri.res.in>, "Sanjaya K. Chihnara" <sanjayakumar@rrimail.rri.res.in>
|
|
6
|
+
License: RRI
|
|
7
|
+
Requires-Python: >=3.11.8
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: astropy
|
|
10
|
+
Requires-Dist: healpy
|
|
11
|
+
Requires-Dist: scipy
|
|
12
|
+
Requires-Dist: h5py
|
garib-0.0.1/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: garib
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: This packages eliminates the observation times when the beam of the radio antenna crosses the a rectangular region in the sky.
|
|
5
|
+
Author-email: "Abhijeet S. Patil" <abhijeet@rrimail.rri.res.in>, "Sanjaya K. Chihnara" <sanjayakumar@rrimail.rri.res.in>
|
|
6
|
+
License: RRI
|
|
7
|
+
Requires-Python: >=3.11.8
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: astropy
|
|
10
|
+
Requires-Dist: healpy
|
|
11
|
+
Requires-Dist: scipy
|
|
12
|
+
Requires-Dist: h5py
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
GARIB/__init__.py
|
|
4
|
+
GARIB/garib.py
|
|
5
|
+
GARIB/h5py_file_open.py
|
|
6
|
+
GARIB/testing.py
|
|
7
|
+
garib.egg-info/PKG-INFO
|
|
8
|
+
garib.egg-info/SOURCES.txt
|
|
9
|
+
garib.egg-info/dependency_links.txt
|
|
10
|
+
garib.egg-info/requires.txt
|
|
11
|
+
garib.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GARIB
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "garib"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
|
|
5
|
+
description = "This packages eliminates the observation times when the beam of the radio antenna crosses the a rectangular region in the sky."
|
|
6
|
+
|
|
7
|
+
dependencies = [
|
|
8
|
+
"numpy",
|
|
9
|
+
"astropy",
|
|
10
|
+
"healpy",
|
|
11
|
+
"scipy",
|
|
12
|
+
"h5py",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
license = { text = "RRI" }
|
|
16
|
+
|
|
17
|
+
requires-python = ">=3.11.8"
|
|
18
|
+
|
|
19
|
+
authors = [
|
|
20
|
+
{ name = "Abhijeet S. Patil", email = "abhijeet@rrimail.rri.res.in" },
|
|
21
|
+
{ name = "Sanjaya K. Chihnara", email = "sanjayakumar@rrimail.rri.res.in" },
|
|
22
|
+
]
|
garib-0.0.1/setup.cfg
ADDED