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 radiacode #15

Merged
merged 1 commit into from
Sep 11, 2023
Merged

Add radiacode #15

merged 1 commit into from
Sep 11, 2023

Conversation

ckuethe
Copy link
Contributor

@ckuethe ckuethe commented Sep 7, 2023

Add support for RadiaCode-10x PSRDs

This diff, heavily inspired by the ARAM and MicroRaider drivers, adds support for RadiaCode-102 PSRDs - actually the XML data file as produced by their Android app v1.42.00, as these devices do not natively emit log files. This probably works with the previous generation RadiaCode-101 devices and XML output from their iOS and Windows apps too, but isn't tested.

There are some attributes I'm not sure about, eg. scintillator volume and dead time; I've contacted the manufacturer for more information and have yet to hear back. Since I can't say for sure what the live time is compared to the real time, the live time is unset and only the real time is reported.

A sample XML file containing both foreground and background spectra is at https://gist.github.com/ckuethe/0673bc9028a200c6e6ae31f570ae4142

This diff has been tested with convert_to_n42 and a patched version of cambio

ckuethe@thorium:build$ ./SpecUtils/examples/convert_to_n42 /tmp/MysterySpectrum.xml out.n42
Trying to autodetect /tmp/MysterySpectrum.xml
'/tmp/MysterySpectrum.xml' is a valid spectrum file with 2 spectrum records (composed of2 time records of 1 detectors).
The sum real time of the measurements is 38932 seconds, with live time 0 seconds.
The first record has 1024 gamma channels.
Wrote 'out.n42'

InterSpec-linux-x64_v1.0.11 is able to load the resulting N42 file.

This diff, heavily inspired by ARAM and MicroRaider, adds support for
RadiaCode-102 PSRDs - actually the XML data file as produced by their
Android app v1.42.00, as these devices do not natively emit log files.
This probably works with the previous generation RadiaCode-101 devices
and XML output from their iOS and Windows apps too, but isn't tested.

There are some attributes I'm not sure about, eg. scintillator volume and
dead time; I've contacted the manufacturer for more information and have
yet to hear back. Since I can't say for sure what the live time is compared
to the real time, the live time is unset and only the real time is reported.

A sample XML file containing both foreground and background spectra is at
https://gist.github.com/ckuethe/0673bc9028a200c6e6ae31f570ae4142

Tested with `convert_to_n42` and `cambio`

```
ckuethe@thorium:build$ ./SpecUtils/examples/convert_to_n42 /tmp/MysterySpectrum.xml out.n42
Trying to autodetect /tmp/MysterySpectrum.xml
'/tmp/MysterySpectrum.xml' is a valid spectrum file with 2 spectrum records (composed of2 time records of 1 detectors).
The sum real time of the measurements is 38932 seconds, with live time 0 seconds.
The first record has 1024 gamma channels.
Wrote 'out.n42'
```
@wcjohns
Copy link
Collaborator

wcjohns commented Sep 7, 2023

Wow - this is really great Chris - thank you for adding support for this file format!

I'm impressed you found all the disparate places in the code required to fully add the format.
The example file is also really helpful to add to the regression and fuzz testing.

Before accepting this pull request, there are a few things I need to do (regression testing, fuzz testing, and something else I will email you about), and I am a little busy for the next few weeks, but I'lll try to carve out some time, but it may be a little while - I'm sorry in advance for this.

Again thank you for this, it looks great.
-will

@@ -4494,6 +4504,14 @@ bool SpecFile::load_file( const std::string &filename,
}//if( orig_file_ending=="xml" )


if( orig_file_ending=="xml" || orig_file_ending=="rco")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

RadiaCode exports as .xml by default, '.rco' is my local convention to indicate that this XML file is radiacode data and not ... some other thing.


if( orig_file_ending.empty() )
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 had to add this to make autodetection work correctly. Without it, neither cambio nor convert_to_n42 were able to guess the file format.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll also take a look at this - in practice, filenames often get mangled, or given different extensions, by the time the user gets them, so I'll make sure the code will parse even without a filename.

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 was the least disruptive way I could think of to get autodetection to work. I just wanted you to be aware of this change so you didn't think it was an unintentional or malicious change.

Given the way autodetection appears intended to work, and the way the format libraries seem to be structured, that entire file ending business should be entirely unnecessary if the code is literally going to try every format until one returns success.

@ckuethe
Copy link
Contributor Author

ckuethe commented Sep 7, 2023

You're welcome. Happy to receive feedback and make whatever changes might be necessary to be able to merge this diff. :)

@wcjohns wcjohns merged commit 56058d6 into sandialabs:master Sep 11, 2023
@wcjohns
Copy link
Collaborator

wcjohns commented Sep 11, 2023

Thank you again for this Chris!
I'll make a few very minor followup changes, and add supporting "spectrogram" data to my TODO list.

@ckuethe
Copy link
Contributor Author

ckuethe commented Sep 11, 2023

Thanks!

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.

None yet

3 participants