fermi-lat / Likelihood

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

ValueError: could not convert string to float - make4FGLxml.py #87

Closed omersajid9 closed 4 years ago

omersajid9 commented 4 years ago

Hi, I am getting an error when I try to make source xml file of Crab data for likelihood analysis. The following is the error I get:

Traceback (most recent call last): File "make4FGLxml.py", line 825, in if name=='main': cli() File "make4FGLxml.py", line 822, in cli sL.makeModel(args.galfile,args.galname,args.isofile,args.isoname,args.normsonly,args.extDir,args.radLim,args.maxRad,args.ExtraRad,args.sigFree,args.varFree,args.psForce,args.E2CAT,args.makeRegion,args.GIndexFree,args.writeDir,args.oldNames) File "make4FGLxml.py", line 69, in makeModel addSrcsXML(self,GDfile,GDname,ISOfile,ISOname,oldNames) File "make4FGLxml.py", line 156, in addSrcsXML elif float(src.getAttribute('TS_value'))>=sL.sig: ValueError: could not convert string to float:

I've also attached a screenshot: Screenshot from 2020-06-26 21-39-14

In order to find the problem, I edited the make4FGLxml.py file to print the TS values. I added print(src.getAttribute('TS_value')) to the code and found out that there is a non-float-string value. Please find attached the log file which shows the non-float-string value just before the error. I tried to perform the command with different data sets of Crab, but always get the same error. make4FGLxml_error.log

joeastro commented 4 years ago

Hello,

I tried to reproduce this issue, but was unsuccessful (i.e. it ran fine for me). Would it be possible to share your filtered events file, or list the inputs used to create it (source coordinates, time cuts, search radius, etc.)?

Thanks, Joe Eggen

joeastro commented 4 years ago

Hello,

I was able to reproduce the error that you described, and am investigating the specific issue. In the meantime, I have a simple workaround that should get your project moving again. Simply use the following version of the catalog in your analysis:

https://fermi.gsfc.nasa.gov/ssc/data/access/lat/10yr_catalog/gll_psc_v23.fit

This is the latest version of the 4FGL catalog, made with 10 years of data. Note that it is the .fit version, whereas the one you were using was an .xml file.

I'll post a more detailed breakdown of the issue soon.

omersajid9 commented 4 years ago

Hi,

Thank you for your response. I am getting a similar error when I use the gll_psc_v23.fit file. Screenshot from 2020-06-30 14-13-42 The query ID of the LAT data used here is L2006231434245FCA149A42. I couldn't attach the data files because of their size, but following are the .par files for the gtselect and gtmktime commands. gtmktime.txt gtselect.txt

I tried performing the command with a variety of data sets of Crab but got the same error each time.

joeastro commented 4 years ago

Hi,

It looks like you are using the extended photon files for your analysis - correct? I will download the same and repeat the analysis. For the record, using the normal (and much smaller) photon events files from the dataserver doesn't give me this issue, even when I use all the inputs that you supplied in your previous message.

~Joe

joeastro commented 4 years ago

Hi,

A couple of us at the FSSC have tried to reproduce your second error, but so far we have not been able to do so. As a sanity check, could you try downloading the catalog file gll_psc_23.fit and running the command again? Just checking to make sure the catalog file wasn't corrupted. The size of the file should be 5.2M after download.

For your convenience: wget https://fermi.gsfc.nasa.gov/ssc/data/access/lat/10yr_catalog/gll_psc_v23.fit

omersajid9 commented 4 years ago

Hi,

I tried using simple Photon files and the link you provided, but am getting the same error, with both gll_psc_v23 and gll_psc_v21. image I have also attached onedrive link to the fits file used here: https://1drv.ms/u/s!AsiKHKWHVppmkl4vHZswhtQrn4BY?e=8RCHcg Following is the xml output file it produces: crab_input_model.txt

joeastro commented 4 years ago

Hi,

Unfortunately, we are still unable to reproduce the error you are getting, even when using the filtered events file that you provided. We are still trying to get to the bottom of this issue.

In the meantime, here is the the model file I was able to produce using the file that you provided in the preceding comment. Just change the .txt extension to .xml - GitHub doesn't support .xml attachments, apparently. crab_v23.txt

Cheers, Joe

joeastro commented 4 years ago

Hi,

We are still unable to reproduce the error you are seeing, but perhaps the following diagnostic test will help:

In the make4FGLxml.py script, find the the line that reads: if (dist=x-step) or (x==sL.roi[2]+10. and dist==x):

and insert the following line immediately after it: print(n)

This will print out the names of the sources in sequence as the script goes through them. Perhaps it will help us determine which source, if any, is causing the issue.

Cheers, Joe

omersajid9 commented 4 years ago

Hi,

Thank you for your reply. I get the following output when I edit the python script: Screenshot from 2020-07-07 22-36-14

omersajid9 commented 4 years ago

Hi,

I previously had installed Fermitools using miniconda, but now I reinstalled it using Anaconda and the command runs fine using gll_psc_v23.fit file. I still have miniconda installed on my personal computer and the command doesn't work over there. So I believe the problem is somewhat related to miniconda.

Thank you for your help.

donhorner commented 3 years ago

FYI, Tyrel Johnson updated the make4FGLxml.py script so that using the XML version of the catalog will not result in the error originally reported. We posted the update to User Contributed Software page.