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

round guide count and P2 #378

Merged
merged 8 commits into from
Dec 2, 2021
Merged

round guide count and P2 #378

merged 8 commits into from
Dec 2, 2021

Conversation

javierggt
Copy link
Contributor

@javierggt javierggt commented Nov 12, 2021

Description

This PR adds changes to round P2 and guide count so we do not get warnings due to numerical errors (like we got in NOV1521A.

Testing

  • Functional testing. I ran this version on the NOV1521A loads. The result is here, and the diff between the two starcheck files is here

Copy link
Contributor

@jeanconn jeanconn left a comment

Choose a reason for hiding this comment

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

Looks good to me. _guide_count looks to be explicitly returning a float, and the P2 from proseco_probs is explicitly a float, so the sprintf behavior should round it. In the absence of unit tests I generally just try to find weeks that show what we want for functional tests.

@jeanconn
Copy link
Contributor

So the NOV1521A functional test shows that the bright guide count is working. I figure we probably also want functional test coverage of the OR guide count and P2, or could let them go...

@javierggt
Copy link
Contributor Author

What do you mean by "functional test coverage of the OR guide count and P2"?

Wouldn't that show up in the same output? I posted a diff file to make it easier.

@javierggt
Copy link
Contributor Author

the OR guide count is already rounded in the output, it seems, so there is no associated diff.

@jeanconn
Copy link
Contributor

jeanconn commented Nov 12, 2021

Right, and for the P2 it seems like we should probably update the format string for the print as well (unless the zeros are now reassuring).

Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

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

Overall the use of sprintf to do rounding and turn the value into a string really seems horrible. But this is perl and after a bit of googling that does seem to be the idiom. So 👍 on this. The question is just about functional testing and interface changes.

And speaking of which, is this a good time to include the guide count in the starcheck per-obsid report instead of just in the summary up top?.

@@ -2269,7 +2269,7 @@ sub print_report {
my $bad_FOM = $self->{figure_of_merit}->{cum_prob_bad};
$o .= "$red_font_start" if $bad_FOM;
$o .= "Probability of acquiring 2 or fewer stars (10^-x):\t";
$o .= substr(sprintf("%.4f", $self->{figure_of_merit}->{P2}), 0, 6) . "\t";
$o .= substr(sprintf("%.1f", $self->{figure_of_merit}->{P2}), 0, 3) . "\t";
Copy link
Member

Choose a reason for hiding this comment

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

What is the substr for here? I see the logic in the change but the original code is confusing me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am betting this can be removed.

I can imagine something like this to truncate the number if the rounded number takes more digits than expected, but it is also not a very good idea.

Copy link
Contributor Author

@javierggt javierggt Nov 12, 2021

Choose a reason for hiding this comment

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

this could related to sprintf actually rounding a float and not giving a string as output. When you round, you might not get a number with exact binary representation, and then when you concatenate and print you get 0.9000001 instead of 0.9, so you truncate the string.

(although I think what I just said would be crazy, I doubt that can be, can it?)

Copy link
Member

Choose a reason for hiding this comment

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

As long as I'm trying out perl... I feel like the substr is not helping out here. In the unlikely event that P2 is > 10 or negative, the substr would give a bad result.

perl -e '$a="10.23432"; $b=substr($a, 0, 3); print("$b\n")'
10.

@javierggt
Copy link
Contributor Author

I also do not like the use of sprintf. I could do int(10*$number + 0.5)/10 or something like that, but I also googled... so...

@jeanconn
Copy link
Contributor

Agreed. And I commented on the inputs being floats because I seemed to remember that was the "gotcha" with using sprintf this way (I don't think it rounds if they are already strings)... but I didn't test.

@taldcroft
Copy link
Member

(I don't think it rounds if they are already strings)... but I didn't test.

Looks like it works...

perl -e '$a="1.23432"; $b=sprintf("%.1f", $a); print($b)'
1.2

@jeanconn
Copy link
Contributor

I think your example is not super reassuring, but agree that sprintf looks to round correctly even if the thingy is already a string (I suppose that makes sense it needs to cast to print the float with decimal places anyway).

ska3-fido$ perl -e '$a="1.29432"; $b=sprintf("%.1f", $a); print("$b\n");'
1.3

Good perl reminder.

@jeanconn
Copy link
Contributor

Wrt "And speaking of which, is this a good time to include the guide count in the starcheck per-obsid report instead of just in the summary up top?." I went ahead and did that in some commits in this PR after Javier's. I also just added the guide count to the per-obsid stuff at the bottom. It turns out that chunk is not parsed by the parser anyway, so seems not a problem/complication.

@jeanconn
Copy link
Contributor

I put updated output at https://icxc.cfa.harvard.edu/aspect/tmp/starcheck-pr378-v2/starcheck.html and https://icxc.cfa.harvard.edu/aspect/tmp/starcheck-pr378-v2/diff.html though I note we run into the little issue that as it gets further from NOV1521, we get more critical warnings on magnitude mismatches as the supplement has updated.

There might be value in adding an option to starcheck to use the mags from previous starcheck outputs. (just disabling the supplement seems not the right thing and keeping the critical warning still seems safe).

@taldcroft
Copy link
Member

What about outputting the ER guide star count which has been the driver here?

@taldcroft
Copy link
Member

About >> CRITICAL: [4] Guide sum mag diff from agasc mag 0.01170, this is definitely not critical in the way that it was when the check was first included. I think it can be demoted to caution or info.

@jeanconn
Copy link
Contributor

Good point about the ER bright star count. I was missing that tree in this forest. So, do we want that in the two places, the summary at top and the standard matter at the bottom of an obsid (though this one would only be for ERs or we could include the ER bright star count on ERs and the OR guide count for ORs).

@jeanconn
Copy link
Contributor

I don't feel strongly about demoting the guide mag diff critical, just because it shouldn't come up in flight products. For test work, demoting the warning doesn't fix the problem.

@taldcroft
Copy link
Member

I don't think we need to put the ER count in the summary, but I do think we should have both the ER count and the regular count in the detail text for ERs since both are checked (IIRC?).

@taldcroft
Copy link
Member

I don't feel strongly about demoting the guide mag diff critical, just because it shouldn't come up in flight products. For test work, demoting the warning doesn't fix the problem.

Well at least it would let us pass test products without a Note related to this issue.

@jeanconn
Copy link
Contributor

If the note were based on the diff of all warnings... demoting wouldn't really help... but if it is your preference that's fine.

@jeanconn
Copy link
Contributor

OK. I added the count of bright guide stars to the ER standard reporting.

@jeanconn jeanconn requested a review from taldcroft November 29, 2021 18:33
@taldcroft
Copy link
Member

Can you make the latest output available somewhere? The top description should be updated with relevant permalinks for the functional testing / evaluation.

Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

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

Looks basically OK apart from the one comment, but I'd like to see the output and diff.

starcheck/src/lib/Ska/Starcheck/Obsid.pm Show resolved Hide resolved
@jeanconn
Copy link
Contributor

jeanconn commented Dec 2, 2021

The output and diff through 8d9e865 are now in https://icxc.cfa.harvard.edu/aspect/tmp/starcheck-pr378-v3/ (functional testing comment at top updated). Still not sure if you want to call count_guide_stars() again for the summary check; could go either way on that.

@jeanconn jeanconn requested a review from taldcroft December 2, 2021 18:11
@jeanconn
Copy link
Contributor

jeanconn commented Dec 2, 2021

And @javierggt I apparently can't ask for your review because it is your PR but...

Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@jeanconn jeanconn merged commit d52a819 into master Dec 2, 2021
@jeanconn jeanconn deleted the round_bright_count branch December 2, 2021 20:02
@jeanconn jeanconn mentioned this pull request Dec 3, 2021
@javierggt javierggt mentioned this pull request Aug 3, 2022
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.

3 participants