jolly-roger 0.0.2__py3-none-any.whl → 0.1.0__py3-none-any.whl

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.

Potentially problematic release.


This version of jolly-roger might be problematic. Click here for more details.

jolly_roger/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.0.2'
21
- __version_tuple__ = version_tuple = (0, 0, 2)
20
+ __version__ = version = '0.1.0'
21
+ __version_tuple__ = version_tuple = (0, 1, 0)
@@ -8,15 +8,14 @@ from typing import Literal
8
8
 
9
9
  import astropy.units as u
10
10
  import numpy as np
11
- from astropy.coordinates import EarthLocation, SkyCoord, get_sun
11
+ from astropy.coordinates import AltAz, EarthLocation, SkyCoord, get_sun
12
12
  from astropy.time import Time
13
13
  from casacore.tables import table
14
14
 
15
15
  from jolly_roger.logging import logger
16
16
 
17
17
  # Default location with XYZ based on mean of antenna positions
18
- ASKAP_XYZ_m = np.array([-2556146.66356375, 5097426.58592797, -2848333.08164107]) * u.m
19
- ASKAP = EarthLocation(*ASKAP_XYZ_m)
18
+ ASKAP = EarthLocation.of_site("ASKAP")
20
19
 
21
20
 
22
21
  @dataclass
@@ -75,6 +74,9 @@ def _process_position(
75
74
  if position == "sun":
76
75
  logger.info("Getting sky-position of the sun")
77
76
  position = get_sun(times)
77
+ else:
78
+ logger.info(f"Getting sky-position of {position=}")
79
+ position = SkyCoord.from_name(position)
78
80
 
79
81
  if position is None:
80
82
  if ms_path is None:
@@ -83,8 +85,8 @@ def _process_position(
83
85
 
84
86
  with table(str(ms_path / "FIELD")) as tab:
85
87
  logger.info(f"Getting the sky-position from PHASE_DIR of {ms_path=}")
86
- field_positions = tab.getcol("PHASE_DIR")
87
- position = SkyCoord(field_positions[0] * u.rad)
88
+ field_positions = tab.getcol("PHASE_DIR")[:]
89
+ position = SkyCoord(*(field_positions * u.rad).squeeze())
88
90
 
89
91
  if isinstance(position, SkyCoord):
90
92
  return position
@@ -116,7 +118,7 @@ def make_hour_angles_for_ms(
116
118
  logger.info(f"Computing hour angles for {ms_path=}")
117
119
  with table(str(ms_path), ack=False) as tab:
118
120
  logger.info("Extracting timesteps and constructing time mapping")
119
- times_mjds = tab.getcol("TIME_CENTROID")
121
+ times_mjds = tab.getcol("TIME_CENTROID")[:] * u.s
120
122
 
121
123
  # get unique time steps and make sure they are in their first appeared order
122
124
  times_mjds, indices = np.unique(times_mjds, return_index=True)
@@ -127,33 +129,28 @@ def make_hour_angles_for_ms(
127
129
  if whole_day:
128
130
  logger.info(f"Assuming a full day from {times_mjds} MJD (seconds)")
129
131
  time_step = times_mjds[1] - times_mjds[0]
130
- times_mjds = times_mjds[0] + time_step * np.arange(
131
- int(60 * 60 * 24 / time_step)
132
+ times_mjds = np.arange(
133
+ start=times_mjds[0],
134
+ stop=times_mjds[0] + 24 * u.hour,
135
+ step=time_step,
132
136
  )
133
137
 
134
- times = Time(times_mjds / 60 / 60 / 24, format="mjd")
138
+ times = Time(times_mjds, format="mjd", scale="utc")
135
139
 
136
- sky_position: SkyCoord = _process_position(
137
- position=position, times=times, ms_path=ms_path
138
- )
140
+ sky_position = _process_position(position=position, times=times, ms_path=ms_path)
139
141
 
140
142
  lst = times.sidereal_time("apparent", longitude=location.lon)
141
- hour_angle = lst - sky_position.ra
142
- mask = hour_angle > 12 * u.hourangle
143
- hour_angle[mask] -= 24 * u.hourangle
143
+ hour_angle = (lst - sky_position.ra).wrap_at(12 * u.hourangle)
144
144
 
145
145
  logger.info("Creatring elevation curve")
146
- sin_alt = np.arcsin(
147
- np.sin(location.lat) * np.sin(sky_position[0].dec.rad)
148
- + np.cos(location.lat) * np.cos(sky_position.dec.rad) * np.cos(hour_angle)
149
- ).to(u.rad)
146
+ altaz = sky_position.transform_to(AltAz(obstime=times, location=location))
150
147
 
151
148
  return PositionHourAngles(
152
149
  hour_angle=hour_angle,
153
150
  time_mjds=times_mjds,
154
151
  location=location,
155
152
  position=sky_position,
156
- elevation=sin_alt,
153
+ elevation=altaz.alt.to(u.rad),
157
154
  time=times,
158
155
  time_map=time_map,
159
156
  )
jolly_roger/uvws.py CHANGED
@@ -44,12 +44,11 @@ def xyz_to_uvw(
44
44
  """
45
45
  b_xyz = baselines.b_xyz
46
46
 
47
- # Getting the units right is important, mate
48
- ha = hour_angles.hour_angle
49
- ha = ha.to(u.rad)
47
+ # Convert HA to geocentric hour angle (at Greenwich meridian)
48
+ # This is why we subtract the location's longitude
49
+ ha = hour_angles.hour_angle - hour_angles.location.lon
50
50
 
51
51
  declination = hour_angles.position.dec
52
- declination = declination.to(u.rad)
53
52
 
54
53
  # This is necessary for broadcastung in the matrix to work.
55
54
  # Should the position be a solar object like the sub its position
@@ -71,21 +70,22 @@ def xyz_to_uvw(
71
70
  [sin_ha, cos_ha, zeros],
72
71
  [-sin_dec * cos_ha, sin_dec * sin_ha, cos_dec],
73
72
  [
74
- np.cos(declination) * np.cos(ha),
75
- np.cos(declination) * np.sin(ha),
76
- np.sin(declination),
73
+ cos_dec * cos_ha,
74
+ -cos_dec * sin_ha,
75
+ sin_dec,
77
76
  ],
78
77
  ]
79
78
  )
80
79
 
81
80
  # Every time this confuses me and I need the first mate to look over.
82
- # b_xyz shape: (baselines, coord) where coord is XYZ
81
+ # b_xyz shape: (baselines, 3) where coord is XYZ
83
82
  # mat shape: (3, 3, timesteps)
84
- # uvw shape: (baseline, coord, timesteps) where coord is UVW
85
- uvw = np.einsum("ijk,lj->lik", mat, b_xyz, optimize=True) # codespell:ignore lik
83
+ # uvw shape: (3, baseline, timesteps) where coord is UVW
84
+ uvw = np.einsum("ijk,lj->ilk", mat, b_xyz, optimize=True) # codespell:ignore ilk
85
+ # i,j,k -> (3, 3, time)
86
+ # l,j -> (baseline, 3)
87
+ # i,l,k -> (3, baseline, time)
86
88
 
87
- # Make order (coord, baseline, timesteps)
88
- uvw = np.swapaxes(uvw, 0, 1)
89
89
  logger.debug(f"{uvw.shape=}")
90
90
 
91
91
  return UVWs(uvws=uvw, hour_angles=hour_angles, baselines=baselines)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jolly-roger
3
- Version: 0.0.2
3
+ Version: 0.1.0
4
4
  Summary: The pirate flagger
5
5
  Project-URL: Homepage, https://github.com/flint-crew/jolly-roger
6
6
  Project-URL: Bug Tracker, https://github.com/flint-crew/jolly-roger/issues
@@ -1,14 +1,14 @@
1
1
  jolly_roger/__init__.py,sha256=7xiZLdeY-7sgrYGQ1gNdCjgCfqnoPXK7AeaHncY_DGU,204
2
- jolly_roger/_version.py,sha256=wO7XWlZte1hxA4mMvRc6zhNdGm74Nhhn2bfWRAxaKbI,511
2
+ jolly_roger/_version.py,sha256=-LyU5F1uZDjn6Q8_Z6-_FJt_8RE4Kq9zcKdg1abSSps,511
3
3
  jolly_roger/_version.pyi,sha256=j5kbzfm6lOn8BzASXWjGIA1yT0OlHTWqlbyZ8Si_o0E,118
4
4
  jolly_roger/baselines.py,sha256=C_vC3v_ciU2T_si31oS0hUmsMNTQA0USxrm4118vYvY,4615
5
5
  jolly_roger/flagger.py,sha256=tlC-M_MpLpqOvkF544zw2EvOUpbSpasO2zlMlXMcxSs,3034
6
- jolly_roger/hour_angles.py,sha256=ChWTy69dkRN0R2HWEknHagv6W3xTXuSJJn9sAqBABCc,6160
6
+ jolly_roger/hour_angles.py,sha256=SUUN_DcT3xzYp9JZ1U9ZcJpMjsfYETJ4D0YghUjee7Y,6096
7
7
  jolly_roger/logging.py,sha256=04YVHnF_8tKDkXNtXQ-iMyJ2BLV-qowbPAqqMFDxYE4,1338
8
8
  jolly_roger/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- jolly_roger/uvws.py,sha256=8G2E7bq8y5EEc2wQW5nli1WKsebZbBEHN8fhPzlinWk,10558
10
- jolly_roger-0.0.2.dist-info/METADATA,sha256=BtHEC57mNeu12PI6_pnDSkD8i767av0kQfTr_vINWuI,4172
11
- jolly_roger-0.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
- jolly_roger-0.0.2.dist-info/entry_points.txt,sha256=ZwEZAe4DBn5nznVI0tP0a1wUinYouwXxxcZP6p7Pkvk,58
13
- jolly_roger-0.0.2.dist-info/licenses/LICENSE,sha256=7G-TthaPSOehr-pdj4TJydXj3eIUmerMbCUSatMr8hc,1522
14
- jolly_roger-0.0.2.dist-info/RECORD,,
9
+ jolly_roger/uvws.py,sha256=42FngtA425Fk8QSlEIbl-9tEBd_-In0FtV2LYcnk6-0,10555
10
+ jolly_roger-0.1.0.dist-info/METADATA,sha256=d40uefWM1e6HJtaqxNoak1PFBNFFZaBaS_18wno_Au8,4172
11
+ jolly_roger-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
+ jolly_roger-0.1.0.dist-info/entry_points.txt,sha256=ZwEZAe4DBn5nznVI0tP0a1wUinYouwXxxcZP6p7Pkvk,58
13
+ jolly_roger-0.1.0.dist-info/licenses/LICENSE,sha256=7G-TthaPSOehr-pdj4TJydXj3eIUmerMbCUSatMr8hc,1522
14
+ jolly_roger-0.1.0.dist-info/RECORD,,