Commits
Kazuhiko Shimada authored f630a079363
1298 1298 | |
1299 1299 | Returns: |
1300 1300 | int: width of a slice. note that the minimum value is 0. |
1301 1301 | """ |
1302 1302 | # adjust index of both side within channel |
1303 1303 | # candidate slice width based on the feature line width |
1304 1304 | _candidate_width = ceil(max(line_width / self.NUM_CHANNELMAP, 1)) |
1305 1305 | # allowed max slice width based on the feature line center |
1306 1306 | _allowed_max_width = max(floor(2.0 * min(line_center + 0.5, self.nchan - line_center - 0.5) / self.NUM_CHANNELMAP), 1) |
1307 1307 | |
1308 - | # both side of the feature line is within the channel, and the candidate width is allowed |
1309 - | if line_center - line_width * 0.5 >= -0.5 and line_center + line_width * 0.5 <= self.nchan - 0.5 \ |
1310 - | and _candidate_width <= _allowed_max_width: |
1308 + | # If both side of the vertical red lines is within nchan, then returns the candidate slice width |
1309 + | if line_center - _candidate_width * self.NUM_CHANNELMAP * 0.5 >= -0.5 and \ |
1310 + | line_center + _candidate_width * self.NUM_CHANNELMAP * 0.5 <= self.nchan - 1 + 0.5: |
1311 1311 | return _candidate_width |
1312 1312 | else: |
1313 - | # one side of the feature line is out of the channel |
1313 + | # If one side of the lines is out of nchan, returns the allowed max slice width |
1314 1314 | return _allowed_max_width |
1315 1315 | |
1316 1316 | def calc_velocity_lines(self, is_leftside:bool, slice_width: int, idx_vertlines: List[int], velocity_line_center:float) -> List[float]: |
1317 1317 | """ |
1318 1318 | Calculate relative velocities for red vertical lines on the velocity plot using extrapolation. |
1319 1319 | |
1320 1320 | Args: |
1321 1321 | is_leftside (bool): the flag whether the center of the feature line is at left side of the channel map |
1322 1322 | slice_width (int): width of a slice |
1323 1323 | idx_vertlines (List[int]): indice of vertical red lines |