Skip to content
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

Use paramio to access parameter information #815

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

DougBurke
Copy link
Member

Fix #780

Unfortunately paramio is a bit-too chatty when it hits an error (like a parameter not having a min, max, or prompt value), and this is handled at the C layer which means contextlib.redirect_stderr can not be used. I forget now how to manually change the stderr channel in such a way to get this to work, so we are stuck with ./mk_runtool.py generating a lot of messages like

/lagado2.real/local/anaconda/envs/ciaox-base/param/csmooth.par: parameter error? : sclmin.p_max
/lagado2.real/local/anaconda/envs/ciaox-base/param/csmooth.par: parameter error? : sclmax.p_max
Note: minval/maxval is INDEF in
  csmooth.sclmax
/lagado2.real/local/anaconda/envs/ciaox-base/param/csmooth.par: parameter error? : stepzero.p_min
/lagado2.real/local/anaconda/envs/ciaox-base/param/csmooth.par: parameter error? : stepzero.p_max

and so hiding any useful information.

I claim that the runtool module this creates is semantically the same as the previous version, but there are textual differences for the floating point values - in particular the minimum and maximum ranges. You see changes like 1.0 -> 1 and 0.5e-4 -> 5e-5.

We can now access all the parameter information we need with
paramio (even if a bit messy), so switch to that rather than
manually parsing the parameter files.

The results aren't identical, but should be "semantically" - e.g.
numeric values are not guaranteed to have the same textual form
but should have the samve value (e.g. 0.5e-4 vs 5e-5 and 1.0 vs 1).
These changes **shold only** be textual and not provide a
semantic difference (e.g. 1.0 vs 1), but we need to check this
assumption out.
@DougBurke DougBurke linked an issue Oct 13, 2023 that may be closed by this pull request
@DougBurke DougBurke merged commit 55d079e into cxcsds:ciao416 Oct 13, 2023
@DougBurke DougBurke deleted the runtool-setup branch October 13, 2023 15:47
@@ -2760,7 +2760,7 @@ def make_tool(toolname):

parinfo['csmooth'] = {
'istool': True,
'req': [ParValue("infile","f","input file name",None),ParValue("sclmap","f","image of user-supplied map of smoothing scales",None),ParValue("outfile","f","output file name",None),ParValue("outsigfile","f","output significance image",'.'),ParValue("outsclfile","f","output scales [kernel sizes] image",'.'),ParSet("conmeth","s","Convolution method.",'fft',["slide","fft"]),ParSet("conkerneltype","s","Convolution kernel type.",'gauss',["gauss","tophat"]),ParValue("sigmin","r","minimal significance, S/N ratio",4),ParRange("sigmax","r","maximal significance, S/N ratio",5,")sigmin",None),ParValue("sclmin","r","initial (minimal) smoothing scale [pixel]",None),ParRange("sclmax","r","maximal smoothing scale [pixel]",None,")sclmin",None),ParSet("sclmode","s","compute smoothing scales or user user-supplied map",'compute',["compute","user"])],
'req': [ParValue("infile","f","input file name",None),ParValue("sclmap","f","image of user-supplied map of smoothing scales",None),ParValue("outfile","f","output file name",None),ParValue("outsigfile","f","output significance image",'.'),ParValue("outsclfile","f","output scales [kernel sizes] image",'.'),ParSet("conmeth","s","Convolution method.",'fft',["slide","fft"]),ParSet("conkerneltype","s","Convolution kernel type.",'gauss',["gauss","tophat"]),ParValue("sigmin","r","minimal significance, S/N ratio",4),ParRange("sigmax","r","maximal significance, S/N ratio",5,4,None),ParValue("sclmin","r","initial (minimal) smoothing scale [pixel]",None),ParRange("sclmax","r","maximal smoothing scale [pixel]",None,"INDEF",None),ParSet("sclmode","s","compute smoothing scales or user user-supplied map",'compute',["compute","user"])],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOh. This one is an interesting change (thanks to the GH view it makes it more obvious what has changed). So sigmax.p_min returns the actual value (after following through the parameter redirection).

Hmmmm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mk_runtool use p_type
1 participant