MWATelescope / mwa_pb

MWA Primary Beam model code
MIT License
2 stars 8 forks source link

Incorrect handling of h5 file missing #2

Closed cjordan closed 5 years ago

cjordan commented 5 years ago

I would attempt to fix this myself, but I'm getting a headache looking at the code. To reproduce:

Sprinkling some prints in beam_full_EE.py shows that if h5filepath == config.h5file: evaluates true, and that code then sets freqs to an empty list (and not a numpy array). The next condition is elif os.path.exists(h5filepath):, and it seems to me that these conditions need to be somehow merged, as putting the h5 file in the expected location (/home/chj/miniconda2/lib/python2.7/site-packages/mwa_pb/data/mwa_full_embedded_element_pattern.h5) fixes the type error.

andreww5au commented 5 years ago

I've just pushed a change that gives an error if the file can't be found - it still sets freqs to an empty list and returns though, so it'll still fail later with the same TypeError. Not sure whether to call sys.exit(-1) if the h5 file isn't found, or to raise an AssertionError at the point where it looks for the file?

cjordan commented 5 years ago

I got the impression that if the h5 file isn't available, then some other beam was used? If that's wrong, then this code should (IMO) throw an exception, otherwise it prints a warning and uses another beam.

andreww5au commented 5 years ago

I've just pushed a version that raises an IOError instead. There's no way that the primary_beam.MWA_Tile_full_EE() function can succeed if the h5 file doesn't exist. If that function throws an exception (because the h5 file with the full EE model can't be found) then it's up to Jack's code in /srclists/srclist_by_beam.py to call a different beam model function, like primary_beam.MWA_Tile_analytic().