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

Update lronacpho to use LROC's newer photometric model and parameters file #4519

Merged
merged 6 commits into from
Apr 28, 2022

Conversation

victoronline
Copy link
Contributor

@victoronline victoronline commented Jun 8, 2021

Description

This update needs to set the default photometric model (LROC_Empirical) to the newer model (2019) and look for the default parameters file in the data/mission/calibration directory. If the old parameter file is provided, the old algorithm(2014) will be used.

Default behavior:
Should use a newer photometric model as default with the newer parameters file (NAC_PHO_LROC_Empirical.0003.pvl).

Optional behavior:
If another pvl is provided with and doesn't specify the algorithm version (NAC_PHO_LROC_Empirical.0001.pvl), then the old photometric model will be used.

If the 2014 version is specified, such as in NAC_PHO_LROC_Empirical.0002.pvl, then the old photometric model will be used.

Related Issue

#4512

Motivation and Context

LROC has created a newer photometric model requiring updated parameters.

How Has This Been Tested?

This has been tested by the science team comparing photometric products using both the old and newer models and validated the results.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation change (update to the documentation; no code change)
  • [] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read and agree to abide by the Code of Conduct
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have added myself to the .zenodo.json document.
  • I have added any user impacting changes to the CHANGELOG.md document.

Licensing

This project is mostly composed of free and unencumbered software released into the public domain, and we are unlikely to accept contributions that are not also released into the public domain. Somewhere near the top of each file should have these words:

This work is free and unencumbered software released into the public domain. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain.

  • I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

… get from calibration file but still backwards compatible if old parameters file exists will use old model
@victoronline
Copy link
Contributor Author

What do we need to do to get this moving forward? Can I work on the missing pieces, like gtest, or do I have to wait for the review to be made?

1 similar comment
@victoronline
Copy link
Contributor Author

What do we need to do to get this moving forward? Can I work on the missing pieces, like gtest, or do I have to wait for the review to be made?

isis/src/lro/apps/lronacpho/LROCEmpirical.cpp Show resolved Hide resolved
isis/src/lro/apps/lronacpho/LROCEmpirical.cpp Outdated Show resolved Hide resolved
isis/src/lro/apps/lronacpho/LROCEmpirical.cpp Show resolved Hide resolved
isis/src/lro/apps/lronacpho/LROCEmpirical.cpp Outdated Show resolved Hide resolved
isis/src/lro/apps/lronacpho/main.cpp Outdated Show resolved Hide resolved
if(algoFile.toLower() == "default" || algoFile.length() == 0){
GetCalibrationDirectory("", calDir);
algoFile = calDir + "NAC_PHO_LROC_Empirical.????.pvl";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can embed this logic in the app XML, see how hical specifies this:

https://github.com/USGS-Astrogeology/ISIS3/blob/dev/isis/src/mro/apps/hical/hical.xml#L1485

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Jesse. Updated with suggested changes.

isis/src/lro/apps/lronacpho/main.cpp Outdated Show resolved Hide resolved
@victoronline
Copy link
Contributor Author

@jessemapel I think I hit all items on your review. Let me know if you need anything else before proceeding.

@victoronline
Copy link
Contributor Author

If there aren't any issues, is there a chance to get this into the next sprint?

@victoronline
Copy link
Contributor Author

@jessemapel Just making sure this doesn't get lost. Please let me know if you still need anything from me.

@jessemapel
Copy link
Contributor

This looks good now. I'm not sure how to handle updating the tests on this. For the moment, can you e-mail me or attach a zip of a test image with the validated output?

@victoronline
Copy link
Contributor Author

Jesse, I'll send that to you here shortly. Thanks.

@jessemapel jessemapel self-assigned this Feb 11, 2022
@jessemapel
Copy link
Contributor

For testing on this, I'd like to see one test that uses the old parameter file, this likely already exists, and one test that uses the new parameter file. The tests should check that the proper parameters are actually being used and that the report is correct.

@victoronline
Copy link
Contributor Author

@scsides,

This is the error I'm getting when changing the app to be callable. I'll take a closer look later tonight but if something jumps out, please let me know. It's probably an easy typo.

In file included from /ser/estore/scratch/isis/development/git_dev/ISIS3/isis/src/lro/apps/lronacpho/lronacpho.h:6:0, from /ser/estore/scratch/isis/development/git_dev/ISIS3/isis/src/lro/apps/lronacpho/main.cpp:2: inc/Isis.h:9:2: error: #error *****Isis.h MUST be included before any other files!***** #error *****Isis.h MUST be included before any other files!***** ^~~~~ In file included from /ser/estore/scratch/isis/development/git_dev/ISIS3/isis/src/lro/apps/lronacpho/lronacpho.h:6:0, from /ser/estore/scratch/isis/development/git_dev/ISIS3/isis/src/lro/apps/lronacpho/main.cpp:2: inc/Isis.h: In function ‘std::map<QString, void*> GuiHelpers()’: inc/Isis.h:71:27: error: redefinition of ‘std::map<QString, void*> GuiHelpers()’ std::map<QString, void *> GuiHelpers() { ^~~~~~~~~~ In file included from /ser/estore/scratch/isis/development/git_dev/ISIS3/isis/src/lro/apps/lronacpho/main.cpp:1:0: inc/Isis.h:71:27: note: ‘std::map<QString, void*> GuiHelpers()’ previously defined here std::map<QString, void *> GuiHelpers() { ^~~~~~~~~~

@jessemapel jessemapel removed their assignment Apr 18, 2022
@Kelvinrr
Copy link
Collaborator

@victoronline I can look at the code if need be, the fact that there seems to be a merge issue here (look at files changed) makes it kinda hard. But basically that error is telling you that ISIS.h is not included where it needs to be. It should only be at the very top of the main.cpp where IsisMain is located and not in <app>.cpp where the app-as-funcs are being defined. Common mistake if you copy pasted code over and forgot to delete #include "Isis.h" at the top.

@victoronline victoronline force-pushed the dev-lronacpho-1 branch 2 times, most recently from 0a48527 to 961eca5 Compare April 19, 2022 02:49
@scsides
Copy link
Contributor

scsides commented Apr 19, 2022

@victoronline: In the version I pulled down earlier, lronacpho.cpp was included, but I don't see it now. It had a semicolon at the end of the #include for Isis.h, but Isis.h only needs to be included in the main. Isis.h actually houses the C++ int main(argc, argv){} function and should not be include anywhere else.

@scsides
Copy link
Contributor

scsides commented Apr 19, 2022

lronacpho.cpp has a { on line 6. Should be ;

From what I'm seeing, the Isis.h error was masking compile/syntax errors like the one above

@victoronline
Copy link
Contributor Author

I'm fixing the merge errors. I'll upload it again here shortly.

@jlaura
Copy link
Collaborator

jlaura commented Apr 26, 2022

@Kelvinrr Are you able to take a look at this today and get a review back to @victoronline?

@victoronline This has merge conflicts that are going to need to be fixed before it is mergeable. Let us know if you have questions about how to handle those.

Thanks!

@victoronline
Copy link
Contributor Author

@jlaura Merge conflicts resolved.

@victoronline
Copy link
Contributor Author

Should I also check the test cub into the data directory?

@jlaura
Copy link
Collaborator

jlaura commented Apr 26, 2022

@victoronline how large is the test cub? We might want to crop not down first if possible.

@Kelvinrr @jessemapel what is the best method to get test data from an external source? Email if small enough and we will check in to the test data on PR merge?


ASSERT_TRUE(prefix.isValid());

QString inCubeFileName = "data/lronacpho/M143947267L.cal.echo.crop.cub";
Copy link
Collaborator

@Kelvinrr Kelvinrr Apr 26, 2022

Choose a reason for hiding this comment

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

Assuming this image is small enough (like single digit MB), you can just check it in as part of this PR. It seems you already cropped it so I image its good as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not a single-digit MB. It is 8.4 MB

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'll crop down to 1 MB and add to PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added test cube

@victoronline
Copy link
Contributor Author

@jlaura I didn't see your comment before I added the test cube. I can still email if needed.

@jlaura
Copy link
Collaborator

jlaura commented Apr 26, 2022

@victoronline Nope, less than a MB and in the data area like @Kelvinrr said is great!

@Kelvinrr is going to give the updated code a review so that we can get it merged since a number of commits have come in since the original review.

Copy link
Collaborator

@Kelvinrr Kelvinrr left a comment

Choose a reason for hiding this comment

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

Just a few questions, overall looks fine to me. The only other change I would make before approving is adding a line to CHANGELOG.MD under "Unreleased", basically a short description of the change with a link to the relevant issue similar to the history logs. After that I'll approve assuming no other objections from anyone else and we can get this merged.

Comment on lines 355 to 357
pars.aTerms.push_back(toDouble(ConfKey(profile, "A" + toString(i), toString(0.0))));
for (int i=0; i<7; i++)
pars.bTerms.push_back(toDouble(ConfKey(profile, "B" + toString(i), toString(0.0))));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed Jesse suggested changing the toString call with the string literal "0.0", and that you made the change, was this reverted somehow? Or do you need to explicitly cast to a QString?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This must have gotten reverted when I corrected the merge issue. Thanks. Fixed in code.

pars.wavelength = toDouble(ConfKey(profile, "BandBinCenter", toString(Null)));
pars.tolerance = toDouble(ConfKey(profile, "BandBinCenterTolerance", toString(Null)));
// Determine equation units - defaults to Radians
pars.units = ConfKey(profile, "Units", QString("Radians"));
pars.phaUnit = (pars.units.toLower() == "degrees") ? 1.0 : rpd_c();
pars.algoVersion = toInt(ConfKey(profile, "AlgorithmVersion", QString("0")));
Copy link
Collaborator

Choose a reason for hiding this comment

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

same string question here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This must have gotten reverted when I corrected the merge issue. Thanks. Fixed in code.

Comment on lines 9 to 10
extern void lronacpho(Cube *iCube, UserInterface &ui, Pvl *log=nullptr);
extern void lronacpho(UserInterface &ui, Pvl *appLog=nullptr);
Copy link
Collaborator

Choose a reason for hiding this comment

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

kinda minor, but might as well change appLog here to log for consistency with how they're defined in the rest of the lronacpho signatures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in code.

Comment on lines +124 to +129
LineManager oLine(outputCube);
oLine.SetLine(300);
outputCube.read(oLine);

EXPECT_NEAR(oLine[300],algo3Result, 0.002);
outputCube.close();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Anything particular about this DN that makes it important to check or is it a random sample?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a random sample compared to the same output using fx equation the science team is using manually. I would've included testing against fx so any random pixel value could be checked but fx isn't yet callable. This should be updated once it is in case a cube that doesn't have (300,300) pixel.

@jlaura
Copy link
Collaborator

jlaura commented Apr 27, 2022

@victoronline Do you need anything else from us on this right now or are you good with making the minor adjustments based on the re-review? Then we can get this merged and start on the next PR.

@victoronline
Copy link
Contributor Author

@jlaura I should be able to address the items above shortly. Appreciate the note.

@victoronline
Copy link
Contributor Author

victoronline commented Apr 27, 2022

I don't know the etiquette regarding who does the "Resolve conversation" here so I left it up to the reviewer to resolve.

@victoronline
Copy link
Contributor Author

@Kelvinrr @jlaura Do you all need anything else from me to get this merged?

Copy link
Collaborator

@Kelvinrr Kelvinrr left a comment

Choose a reason for hiding this comment

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

@victoronline looks good! 🎉

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.

5 participants