-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT: add argument to specify calibration correction direction #47
FEAT: add argument to specify calibration correction direction #47
Conversation
We had some discussion about this on the last dev call but not many of us attended. So I'd encourage people to comment. @asb5468 could you add a comment with what you said on the call? |
73d0e80
to
e342d79
Compare
@ColmTalbot FWIW, I like this change, particularly the description and choices in the keyword argument if correction.lower() == "data":
amplitude_median = 1 / calibration_data[1] - 1
phase_median = -calibration_data[2]
amplitude_sigma = (1 / calibration_data[3] - 1 / calibration_data[5]) / 2
phase_sigma = (calibration_data[6] - calibration_data[4]) / 2
else:
amplitude_median = calibration_data[1] - 1
phase_median = calibration_data[2]
amplitude_sigma = (calibration_data[5] - calibration_data[3]) / 2
phase_sigma = (calibration_data[6] - calibration_data[4]) / 2 I might throw an |
This lgtm. |
bilby/gw/detector/calibration.py
Outdated
def read_calibration_file(filename, frequency_array, number_of_response_curves, starting_index=0): | ||
""" | ||
Function to read the hdf5 files from the calibration group containing the physical calibration response curves. | ||
def read_calibration_file(filename, frequency_array, number_of_response_curves, starting_index=0, correction=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a minor point, but can the new parameter be called correction_type
rather than correction
? The latter to me seems like an optional boolean variable, like whether to implement a higher-order correction.
bilby/gw/detector/calibration.py
Outdated
@@ -27,6 +33,9 @@ def read_calibration_file(filename, frequency_array, number_of_response_curves, | |||
starting_index: int | |||
Index of the first curve to use within the array. This allows for segmenting the calibration curve array | |||
into smaller pieces. | |||
correction: str | |||
How the correction is defined, either to the data (default) or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest either (i) we make correction='data'
instead of None
, or (ii) change the text here to say something like traditional
or usual
rather than default
. I suspect (ii) is better, as we want to avoid cases where people don't know which one they are doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the issue here that None
is mapped internally to data
ad so data
technically isn't the default value? I'm not really concerned about that as practically the default is data
.
bilby/gw/detector/calibration.py
Outdated
@@ -82,10 +110,33 @@ def write_calibration_file(filename, frequency_array, calibration_draws, calibra | |||
Shape is (number_of_response_curves x len(frequency_array)) | |||
calibration_parameter_draws: data_frame | |||
Parameters used to generate the random draws of the calibration response curves | |||
correction: str | |||
How the correction is defined, either to the data (default) or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here as on L37 https://github.com/bilby-dev/bilby/pull/47/files#r1795826808
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broadly LGTM! I have left a few comments; I also agree with suggestions raised by Sylvia and Will.
bilby/gw/prior.py
Outdated
@@ -1138,7 +1138,7 @@ def to_file(self, outdir, label): | |||
@staticmethod | |||
def from_envelope_file(envelope_file, minimum_frequency, | |||
maximum_frequency, n_nodes, label, | |||
boundary="reflective"): | |||
boundary="reflective", correction=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with correction
-> correction_type
, but also I think the default in the signature should be correction_type='data'
and there should just always be a logger message saying saying what it is doing.
There are a few comments about whether the default should be In future, I'd be in favour of going a step further and either making it a keyword argument without a default, meaning the function cannot be called without specifying the type of correction being used. This would break any codes which do not set it and avoid potential issues due to assumed behaviour/ignoring warnings. |
@farr I agree in principle, in practice, parsing the header of these files is sufficiently difficult that I'd like to at least leave that to a follow up. |
Thanks everyone for the comments! I think I've addressed most of the questions here. The major outstanding point is essentially, should the code always emit a message when reading in the calibration envelopes? Currently, I've set this as a debug statement, so people can see it if they like, but it won't always be printed by default. My main argument for this is that if people have specified the method, then telling them which method is being used is just noise. As a reminder, if users don't specify an option they will get a warning, and probably an error in future versions. Can people react thumbs up for keeping as debug or thumbs down for making this a |
@hoyc1 @SimonStevenson please can you look at this PR if you have a chance? |
156b820
to
cf18a87
Compare
319d0d7
to
9204055
Compare
This is now merged, thanks everyone for the feedback! |
This PR aims to add sufficient flexibility in reading calibration data products to make sure that we correctly map these to the templates in the likelihood. There are probably additional documentation changes that we will want.