Add binary file_format for gauge in 1D#312
Conversation
|
@mandli I uploaded my code again, how to test it again on your side? |
|
@yingjie1234 I just approved the testing. You should get the results shortly. |
|
@yingjie1234 - Thanks for working on this and sorry to be slow to look at this. I haven't gone through the code carefully, but I tried running the example in It runs fine when I set or the other options as a string, but setting throws an error with a similar error if it's set to any list. Also, running |
|
@mandli could you guide on the testing on this part? I can fix this error. thanks! |
|
What we need is to modify one of the tests to also write out the gauges in every format and compare them. I would take the test that you have modified and add a gauge for each format and write code that then reads in the gauges and compares them to each other. Does that make sense? |
|
Yes, I will test it then get back to you soon. |
…ta format parsing, and add verify.py reader
Summary: Add Binary Gauge Output Support (binary32 / binary64)This PR introduces optional binary gauge output to AMRClaw, while keeping ASCII as the default and fully backward-compatible. Key Features1. New
|
|
Thanks @yingjie1234 ! @rjleveque and I will review this and give you feedback if necessary. |
mandli
left a comment
There was a problem hiding this comment.
Here is some basic feedback from a quick read-through.
|
|
||
| # Per-gauge formats: apply same to all gauges | ||
| rundata.gaugedata.file_format = 'binary32' # <= single string | ||
| rundata.gaugedata.display_format = 'e15.7' # only used for ascii; harmless to keep |
There was a problem hiding this comment.
May want to clean this up for the example
| self.rundata.gaugedata.file_format = "ascii" # or 1 | ||
| if self.rundata.gaugedata.file_format in ("binary32", 2): | ||
| rtol, atol = 1e-7, 5e-8 | ||
|
|
There was a problem hiding this comment.
I would suggest writing a gauge out for every format available and comparing them all as a test, perhaps with unique tolerances if need be. Each gauge could actually be at the same location, just different formats (just for the test).
There was a problem hiding this comment.
yes, I will do that
|
I should note that the other dimensions could be added to this PR, but as it only modifies the 1D code so far, I wanted to make sure that the current state, if merged, is reflected in the title. |
|
Add per-gauge binary format support and comprehensive tests
|
- Support per-gauge file formats (ascii, binary32, binary64) - Move load_bin to amrclaw/util.py for reusability - Add tests for gauge formats in 1D, 2D, and 3D - Update example to test all formats simultaneously - Fix pytest warnings in test functions
b885066 to
c18fbcc
Compare
|
|
||
| # ipython | ||
| .ipynb_checkpoints | ||
| TESTING_GAUGE_FORMATS.md |
There was a problem hiding this comment.
yes, I did not include it, it only generated on my end.
|
Can you move the tests to |
yes, I already move the tests to |
|
@mandli: is this ready to merge? I ran the example and it seems fine. The only thing I noticed was the warning since |
|
I don't think it's that big of a deal, but we could remove that save as it is on for all module level variables. Probably should not do that, but I have never been completely clear as to what this does. I think we can merge this. Now just need to do it for 2D and 3D. |
#308 This is starting point to fix gauge format. Please give me suggestions on this.
New per-gauge option:
rundata.gaugedata.file_format = 'binary32' (or 'binary64', 'ascii'); defaults to ASCII if unspecified.
New file types:
Each gauge can now write to gaugeXXXXXX.bin with a short ASCII header (e.g., # file_format: binary32).
Binary layout:
[level :: int32] [time :: float32/float64] [q(1:nvar) :: float32/float64]
Buffer management:
Added flush_all_gauges() to write any buffered data during checkpoints.
Updated print_gauges_and_reset_nextLoc() to handle binary output modes.
Example & test:
Updated examples/advection_1d_example1/setrun.py to demonstrate binary mode.
Added src/1d/verify.py — a small Python script using NumPy to read and verify .bin gauge files.