icecube / FIRESONG

FIRst Extragalactic Simulation Of Neutrino and Gamma-ray
Other
18 stars 8 forks source link

problems with $FIRESONG environment variable #63

Closed JostMigenda closed 3 years ago

JostMigenda commented 3 years ago

[As part of the JOSS review.]

The two code samples in the README, which assume that the user has downloaded the repository, result in a FileNotFoundError if the $FIRESONG environment variable is not set to the main FIRESONG directory:

> pwd
/Users/jost/Documents/FIRESONG/firesong/

> python Firesong.py -d 1e-6 --evolution CC2015SNR --zmax 4.0 --fluxnorm 1.44e-8 --index 2.28 --LF SC
Enviromental variable FIRESONG not set
set to ./
##############################################################################
##### FIRESONG initializing  - Calculating Neutrino CDFs #####
Standard candle sources+
Source evolution assumed: CC2015SNR
Local density of neutrino sources: 1e-06/Mpc^3
Total number of neutrinos sources in the Universe: 5566172
Redshift range: 0 - 4.0
Standard Candle Luminosity: 8.2520e+49 erg/yr
##### FIRESONG initialization done #####

Traceback (most recent call last):
  File "Firesong.py", line 214, in <module>
    firesong_simulation(outputdir,
  File "Firesong.py", line 126, in firesong_simulation
    out = output_writer(outputdir, filename)
  File "/Users/jost/opt/anaconda3/envs/firesong/lib/python3.8/site-packages/firesong/input_output.py", line 30, in __init__
    self.output = self.open_file(outputdir, filename)
  File "/Users/jost/opt/anaconda3/envs/firesong/lib/python3.8/site-packages/firesong/input_output.py", line 49, in open_file
    output = open(outputdir+str(filename), "w")
FileNotFoundError: [Errno 2] No such file or directory: './Results/Firesong.out'

Since the README file implies that setting FIRESONG is optional, this example should also work when it is not set.

On a related note, I found it surprising that the output files are written to ${FIRESONG}/Results/ and not to ${FIRESONG}/. While it’s good practice to have a separate folder for output files, I think it would be more intuitive to point this environment variable directly to that output folder. (Or if there is a good reason to point it to the main FIRESONG folder, at least document clearly in the README that this subfolder name is hardcoded.)

ChrisCFTung commented 3 years ago

Results folder is no longer need in the output directory, so the example can be executed even if FIRESONG is not set. I have also added in README the location of the output file, which should help user to locate the output.