Helium6CRES / he6-cres-spec-sims

A python package to simulate cres data for the 6He CRES experiment at CENPA (University of Washington).
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

experiment.load broken #12

Open rjtayl opened 1 month ago

rjtayl commented 1 month ago

I think with our last pull we broke the experiment.load. I suspect this has to do with the changes to the yaml file but haven't had a chance to look into it yet.

I get this error when trying to use the function in cell 7 of the example ipynb:

---------------------------------------------------------------------------
ConstructorError                          Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_21056\3957136019.py in <module>
      6 # experiment_config_path = "C:/Users/rtayl/OneDrive - North Carolina State University/Research/CRES/he6-cres-spec-sims/config_files/spec_example/spec_example_exp.yaml"
      7 
----> 8 sim = ExpResults.load(experiment_config_path =experiment_config_path)

C:/Users/RJ/OneDrive - North Carolina State University/Research/CRES/he6-cres-spec-sims/src.\he6_cres_spec_sims\experiment.py in load(cls, experiment_config_path)
    193         # Open the config file and grab the contents.
    194         with open(experiment_config_path, "r") as f:
--> 195             experiment_params = yaml.load(f, Loader=yaml.FullLoader)
    196 
    197         if experiment_config_path is None:

~\AppData\Roaming\Python\Python37\site-packages\yaml\__init__.py in load(stream, Loader)
     79     loader = Loader(stream)
     80     try:
---> 81         return loader.get_single_data()
     82     finally:
     83         loader.dispose()

~\AppData\Roaming\Python\Python37\site-packages\yaml\constructor.py in get_single_data(self)
     49         node = self.get_single_node()
     50         if node is not None:
---> 51             return self.construct_document(node)
...
    430 
    431 SafeConstructor.add_constructor(

ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/apply:numpy.core.multiarray._reconstruct'
  in "C:\Users\RJ\OneDrive - North Carolina State University\Research\CRES\he6-cres-spec-sims\config_files\ne_051424\ne_051424_exp.yaml", line 6, column 13

expected output is

/media/drew/T7 Shield/spec_sims_results/local_experiments/local_exp_config_example
+++++++++++++++++++++++++++++++++++++++++++++++++

Loading simulation 0 / 11

+++++++++++++++++++++++++++++++++++++++++++++++++
Optimization terminated successfully.
         Current function value: -3.253639
         Iterations: 43
         Function evaluations: 96
Trap width: (-0.04319391632080079,0.04319391632080079)
Maximum Field: 3.2536386230916876

Set field: 3.25, Trap current: 1.8

+++++++++++++++++++++++++++++++++++++++++++++++++

Loading simulation 1 / 11

+++++++++++++++++++++++++++++++++++++++++++++++++
Optimization terminated successfully.
...
Maximum Field: 0.7508396820186829

Set field: 0.75, Trap current: 0.4153845
buzinsky commented 1 month ago

Share your spec_example_exp.yaml? yaml.load() works for me, but in my setup it is called via experiment.py: L 132 It does not call the L195 version. It should at least be broken if this config is not updated

rjtayl commented 1 month ago

Currently looks like this, pretty sure this is just from your pull request.

# he6_cres_spec_sims example config file.
# if sim_daq: you must specify number acquisitions and acquisition time and event rates.

Settings:
    rand_seed: 717
    sim_daq: True #If true will simulate daq and create spec file, if false no need to fill out daq section

Physics:
    events_to_simulate : 10 #if sim_daq==True will instead calculate appropriate event rate for each spec file
    betas_to_simulate : 2
    beta_rate: 1.5e+6
    freq_acceptance_low: 18.0e+9
    freq_acceptance_high: 19.1e+9
    #energy_spectrum:
    #   beta_source: "He6"
    energy:
        #distribution: "dirac"
        #value: 2.4e+5
        distribution: "beta_decay"
        isotope: "He6"
        b: 0
    rho:
        distribution: "uniform_annulus"
        rho_min : 0.0
        rho_max : 5.78e-3
    z:
        distribution: "uniform"
        low : -2.5e-3
        high : 2.5e-3
    min_theta : 89.0
    max_theta : 90.0

EventBuilder:
    main_field : 1.700468
    trap_current : .1
    decay_cell_radius : 5.78e-3

SegmentBuilder:
    segment_length:
        distribution: "exponential"
        tau: 1.0e-3
    start_time:
        distribution: "uniform"
        low : 0
        high : 0.006
    energy_loss:
        distribution: "normal"
        mean : 14
        sigma : 5
    scattering_angle:
        distribution: "fixed"
        value: 0.0
    jump_num_max: 3
    verbose: True

BandBuilder:
    sideband_num: 0
    frac_total_segment_power_cut : 0.01
    harmonic_sidebands: True
    magnetic_modulation: False

TrackBuilder:
    run_length: 60.0e-4

DMTrackBuilder:
    mixer_freq: 17.9e+9

Daq:
    n_files: 2
    spec_length: .006
    freq_bw: 1.2e+9
    freq_bins: 4096
    roach_avg: 2
    roach_inverted_flag: True # this effectively deletes every other file when roach_avg=2
    requant_gain: 17
    noise_file_gain: 17 #requant gain that the noise profile was taken with
    build_labels: False
    gain_noise_csv_path: "./config_files/base_gain_noise.csv"
    spec_prefix: "SNR_dev"
    spec_suffix: "spec"
    threshold_factor: 9
buzinsky commented 1 month ago

Attempted fix: https://github.com/Helium6CRES/he6-cres-spec-sims/pull/13 I am unsure how this was intended to work - I think it has been broken for a while?