Conversation
|
I think that this split is OK for now. You can, however, eliminate the boolean parameters enabling or disabling certain features, because you can deduce them from the other parameters. Set For debiasing, are both error values required? If the user specifies one, does it make sense to use it for both errors, or are they likely to be completely different magnitudes? Does either of them have a sensible default? Depending on the answer to this, you can enable debiasing either if both error parameters are given, or if at least one is given. Everything under Styling (except the colour, which I think it makes sense to keep separate for consistency) should maybe be grouped under a |
errors for stokes Q and U could be different so we need them as separate parameters.
Vector overlay can be line segments or filled squares. Need to consider this in the naming convention. |
Yes, there will definitely be two parameters. But is the user ever likely to use the same value for both, or is it very unlikely? (Actually, it probably doesn't matter -- it would be way too magical to make one default to the other, so we shouldn't do it either way. :) ) |
If stokes Q and U images are created with different clean processes (clean regions, depth, etc), errors can be different. I think we can set them as 0 as default and they are only effective when debiasing is True. |
|
We're trying to eliminate the boolean parameters and deduce them from the options. So in this case, we need to decide if we need both of the errors to be provided, or just one. Will it ever make sense to use one error value and one default error of zero, or are both errors always required to do anything meaningful? |
We need both to be provided if debiasing is True. If one is missing, we should throw an error. |
|
OK, but we don't want the user to have to duplicate information in the high-level API by enabling debiasing explicitly -- we want to deduce whether the user wants to enable debiasing from the debiasing options provided. So if both errors are always needed, it's fine to keep the defaults of If the user provides only one of the errors, we should disable debiasing, but also print a warning (since this is likely to be a mistake). |
@confluence, sorry for the late reply since I am a bit busy this evening. I will take a close look for all your comments tomorrow but would like to make a quick confirmation: Is the modification in 32aae92 what you mean in the quotation above? |
Yes, that's correct! I also suggest that you do the same for I'll also make a few review comments. |
confluence
left a comment
There was a problem hiding this comment.
Some nitpicks about the phrasing in the docstring.
| if pixel_averaging is not None: | ||
| pixel_averaging_enabled = True | ||
| else: | ||
| pixel_averaging_enabled = False |
There was a problem hiding this comment.
You can simplify this and the conditional below like this: pixel_averaging_enabled = pixel_averaging is not None.
| # VECTOR OVERLAY | ||
|
|
||
| @validate(Constant(VectorOverlaySource), Constant(VectorOverlaySource), NoneOr(Number()), Boolean(), NoneOr(Number()), Boolean(), NoneOr(Number()), NoneOr(Number())) | ||
| def configure_vector_overlay(self, angular_source=VectorOverlaySource.CURRENT, intensity_source=VectorOverlaySource.CURRENT, pixel_averaging=4, fractional_intensity=False, threshold=None, debiasing=False, qError=None, uError=None): |
There was a problem hiding this comment.
Naming convention: qError and uError should be q_error and u_error.
| intensity_source : {1} | ||
| The intensity source. | ||
| pixel_averaging : {2} | ||
| The pixel averaging width. Set it to None to disable the usage pixel averaging width. |
There was a problem hiding this comment.
When you mention literals like None in the code, use the ReST markup for code, which is double backticks:
blah blah ``None`` ...
This will format the word as code in the final Sphinx document.
There was a problem hiding this comment.
This should also mention that the default is 4 (plus the units; not sure what those are).
There was a problem hiding this comment.
I would change the last sentence to: "Set to None to disable pixel averaging."
| pixel_averaging : {2} | ||
| The pixel averaging width. Set it to None to disable the usage pixel averaging width. | ||
| fractional_intensity : {3} | ||
| Set polarization intensity to absolute or fractional. |
There was a problem hiding this comment.
I'd rephrase this as: "Enable fractional polarization intensity. By default absolute polarization intensity is used."
| angular_source : {0} | ||
| The angular source. | ||
| intensity_source : {1} | ||
| The intensity source. |
There was a problem hiding this comment.
Both of these should mention that the default is the current image.
| fractional_intensity : {3} | ||
| Set polarization intensity to absolute or fractional. | ||
| threshold : {4} | ||
| The threshold. Set it to None to disable the usage of threshold. |
There was a problem hiding this comment.
I would say: The threshold. By default the threshold is disabled.
(We should probably also mention the units here.)
(If the user doesn't want to enable the threshold, they are more likely to omit the parameter and fall back to the default than to pass in an explicit None.)
| qError : {6} | ||
| The stoke Q Error. | ||
| uError : {7} | ||
| The stoke U Error. |
There was a problem hiding this comment.
stoke -> Stokes, but Error -> error
Once the debiasing parameter is removed, I would revise each of these to be something like: "The Stokes _ error in [units]. Set both this and [other variable name] to enable debiasing. By default debiasing is disabled."
(Edited to swap sentence order in suggested wording and simplify it.)
|
@kswang1029 @confluence
|
confluence
left a comment
There was a problem hiding this comment.
Minor followup comments; it's looking good!
| if q_error is not None and u_error is not None: | ||
| debiasing = True | ||
| elif q_error is None and u_error is None: | ||
| debiasing = False | ||
| else: | ||
| print("q_error and u_error must be both set to enable debiasing.") |
There was a problem hiding this comment.
Please use the logger for this message (you'll have to import it at the top; it's in .util -- see how it's used in e.g. session.py).
You could compact this using syntax similar to the previous lines (as shown below), but it does mean restating part of the same conditional, so I don't feel that strongly about it -- maybe the way it is now is clearer to read.
debiasing = q_error is not None and u_error is not None
if not debiasing and (q_error is not None or u_error is not None):
logger.warning(...)
In the message, please swap "be both" -> "both be". I would also refer to the error variables by their descriptions rather than their variable names here ("The Stokes Q error and the Stokes U error must...")
| The Stokes Q error in Jy/beam. Set both this and ``u_error`` to enable debiasing. The debiasing is disabled by default. | ||
| u_error : {6} | ||
| The Stokes U error in Jy/beam. Set both this and ``q_error`` to enable debiasing. The debiasing is disabled by default. |
There was a problem hiding this comment.
"The debiasing..." should just be "Debiasing..." in the last sentence(s) here.
| The angular source. By default the current image is used. | ||
| intensity_source : {1} | ||
| The intensity source. By default the current image is used. | ||
| pixel_averaging : {2} |
There was a problem hiding this comment.
"in pixel" -> "in pixels"
There was a problem hiding this comment.
(And it needs the default -- I think it's fine to put "The default is 4." as the middle sentence; you don't need to restate the units.)
There was a problem hiding this comment.
Sorry; I selected the wrong lines somehow -- this is related to the pixel averaging description.
|
I made my previous comments before I saw your questions -- answers below.
|
|
@confluence , I added |
|
@confluence, all the descriptions for |
…meters more cleanly. Did some refactoring for legibility. Still to be tested.
confluence
left a comment
There was a problem hiding this comment.
Clearing my own review.
|
@kswang1029 this is now ready for review. (I would like to merge this first, and finalise making the raster / vector overlay / contours interface consistent in #123.) |



This PR is to resolve #79.
@kswang1029 @confluence, I haven't finished this issue yet, but would like to ask a question before going on.
I have added
configure_vector_overlay,set_vector_overlay_color,set_vector_overlay_colormap,apply_vector_overlayandclear_vector_overlaytoimage.py.The
configure_vector_overlayis a huge method with 9 parameters within sinceVectorOverlayStorein the frontend stuck all the parameters intosetVectorOverlayConfigurationaction to set theConfigurationpanel. Nevertheless, for theStylingpanel, it seems that all the parameters are divided into respective actions.My question is: do you prefer the way of dividing these actions into different Python functions? or do you prefer to stuck all these actions into one function , like a
set_vector_overlay_stylingfunction, for setting up the styling panel?