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

Add ASCII opacity parser to mean_opacity_photons class. #54

Merged
merged 13 commits into from
Nov 20, 2024

Conversation

RyanWollaeger
Copy link
Contributor

@RyanWollaeger RyanWollaeger commented Oct 29, 2024

  • Add ASCII grey data parser to MeanOpacity class in mean_opacity_photons.hpp
  • Combine Rosseland and Planck opacity into one Databox, with a 3rd discrete index valued:
    • 0 = Rosseland,
    • 1 = Planck.
  • Add python script for generating power-law opacity ASCII file, and example file for unit test.
  • Add unit test that parses toy opacity file (kap_plaw.txt).

+ Add ZhuTableOpacity photon class with Rosseland-Planck databox.
+ Assume log-log rho-T for DataBox interpolation.
+ Add ZhuTable variant to opac_photons.hpp.
+ Add unit test for ZhuTable variant.

Notes:
- See: Zhaohuan Zhu et al (2021).
- The next step is to convert the Zhu ASCII into HDF5 format(s).
@RyanWollaeger
Copy link
Contributor Author

@brryan @jonahm-LANL - can't seem to add reviewers - anyway here is a preliminary changeset - thanks for the help!

+ Use filesystem header to check extention in ctor.
+ Refactor old ASCII parser to a private function (called if .txt).
+ Add ZhuTable::Save method and use to add HDF5 file.
+ Update unit test to parse HDF5 data instead.

Thanks to Jonah Miller for the suggestion to use the Save method to
create the HDF5 file.
@Yurlungur Yurlungur added the enhancement New feature or request label Nov 1, 2024
Copy link
Collaborator

@Yurlungur Yurlungur 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! Some minor suggestions but overall this seems like a pretty clean implementation. My main suggestion/complaint is to move the data files out of git. If we want to distribute them, we could maybe use github's release machinery. Let's discuss when you have the chance.

test/CMakeLists.txt Outdated Show resolved Hide resolved
RyanWollaeger and others added 3 commits November 1, 2024 16:33
+ Remove Zhu grey table class and unit test.
+ Replace Zhu data table with toy power-law data table.
+ Generalize file-based ctor to take ASCII or HDF5 file.
+ Add sub-test for parsing toy power-law data into MeanOpacity.
@RyanWollaeger RyanWollaeger changed the title Add Zhu dust+molecule+atom table opacity variant and example file. Add ASCII opacity parser to mean_opacity_photons class. Nov 19, 2024
@RyanWollaeger
Copy link
Contributor Author

What do people think about slightly modifying the ASCII format: e.g. extending the header line with min/max density and temperature, so it can be parsed in rather than hard-coded?

@Yurlungur
Copy link
Collaborator

What do people think about slightly modifying the ASCII format: e.g. extending the header line with min/max density and temperature, so it can be parsed in rather than hard-coded?

I'm a bit nervous about doing that if the ASCII file is provided by someone else. However, if we assume control of it, that makes complete sense. You could also just demand the min/max densities be provided as inputs?

@RyanWollaeger
Copy link
Contributor Author

What do people think about slightly modifying the ASCII format: e.g. extending the header line with min/max density and temperature, so it can be parsed in rather than hard-coded?

I'm a bit nervous about doing that if the ASCII file is provided by someone else. However, if we assume control of it, that makes complete sense. You could also just demand the min/max densities be provided as inputs?

That's a fair point - right now, working on adding a preprocessing python script to generate a new file that: verifies the header data, adds the min/max rho-T values to the header calculated from the original file data, and optionally interpolates to a log-log grid in rho-T (if the grid is not log-log already). This might help people vet their data, or provide a starting point. However, we can defer modifying the ASCII that gets parsed in.

+ (Optionally) interpolate using SciPy interp2d.
+ Assert logarithmic grids if is_loglog is specified.
+ Verify number of rho-T points in header in old opacity file.
+ Add min/max rho-T as metadata to header in new opacity file.

Note: this script assumes old ASCII file is in Zhu et al (2021)
grey opacity format, which has a Rosseland and Planck column.
@RyanWollaeger
Copy link
Contributor Author

Just added the old->new ASCII preprocessing script in the last commit, but left the MeanOpacity class alone.

+ Make changes to parser name and comments to remove references.
+ Remove power-law opacity generation script.

Note: the new metadata is redundant with the rho-T column data,
so either might be removed.
+ Remove rho-T parsing from MeanOpacity loadASCII function.
+ Update test ASCII data file example_ascii/kap_plaw.txt.

Note: non-uniform rho-T data points can be interpolated onto
a log-log grid, e.g., with example_ascii/preproc_ascii_opac.py.
@RyanWollaeger
Copy link
Contributor Author

Just added the old->new ASCII preprocessing script in the last commit, but left the MeanOpacity class alone.

Now the loadASCII function is modified to take in a modified format, which has min/max rho-T in the header and no longer has rho-T columns. The preprocessing script has SciPy's 2D interpolation function, so can remap any non-uniformly spaced data that has rho and T columns to a log-log format, as @Yurlungur originally suggested.

@Yurlungur
Copy link
Collaborator

I'm happy with this. @RyanWollaeger @brryan merge when you feel its ready.

Copy link
Collaborator

@brryan brryan left a comment

Choose a reason for hiding this comment

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

Few nitpicking comments, otherwise LGTM! Thanks for adding the test and documentation

@brryan brryan merged commit abdc034 into lanl:main Nov 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants