Telluric-Fitter
Telluric-Fitter copied to clipboard
Installation
I installed now TelFit. However when I try to run it I always get this Warning / Error:
>>>>import os
>>>>os.environ["PYSYN_CDBS"] = "/home/path/PySynphot"
>>>>from telfit import TelluricFitter, DataStructures
>>>>fitter = TelluricFitter()
WARNING:root:Un-locked directory not found! Waiting 10 seconds...
The error repeats every 10s and when I stop the program I get:
----> 1 fitter = TelluricFitter()
/usr/local/lib/python3.10/dist-packages/TelluricFitter.py in init(self, debug, debug_level, print_lblrtm_output) 107 self.debug = debug 108 self.debug_level = debug_level #Number from 1-5, with 5 being the most verbose --> 109 self.Modeler = MakeModel.Modeler(debug=self.debug, print_lblrtm_output=print_lblrtm_output) 110 self.parvals = [[] for i in range(len(self.parnames))] 111 self.chisq_vals = []
/usr/local/lib/python3.10/dist-packages/MakeModel.py in init(self, debug, TelluricModelingDirRoot, nmolecules, print_lblrtm_output) 133 134 #Determine working directories --> 135 self.FindWorkingDirectory() 136 TelluricModelingDir = self.TelluricModelingDir 137 ModelDir = self.ModelDir
/usr/local/lib/python3.10/dist-packages/MakeModel.py in FindWorkingDirectory(self) 319 if not found: 320 logging.warn("Un-locked directory not found! Waiting 10 seconds...") --> 321 time.sleep(10) 322 logging.debug('Telluric Modeling Directory = {}'.format(TelluricModelingDir)) 323 logging.debug('Mode Directory = {}'.format(ModelDir))
Kind regards, Laura
Sorry for the slow reply! TelFit uses 4 "modeling directories" to run LBLRTM in. While running, it marks the directory as running, so that another process doesn't come in and overwrite the various LBLRTM input files. If something breaks while running LBLRTM or reading the output file, that lockfile will remain.
So, long story short you should be able to get past this by manually removing the *.lock
files within ~/.telfit
Sorry for the slow reply! TelFit uses 4 "modeling directories" to run LBLRTM in. While running, it marks the directory as running, so that another process doesn't come in and overwrite the various LBLRTM input files. If something breaks while running LBLRTM or reading the output file, that lockfile will remain. So, long story short you should be able to get past this by manually removing the
*.lock
files within~/.telfit
Hey Thanks for the Help! I know can start the program, if implement os.system('rm $HOME/.TelFit/*.lock')
into my code.
However, if I try to fit, I get the following error (also in the exmaples from GitHub):
Parameter Value Fitting? Bounds
------------- ----- ----- -----
h2o 3.10000E+01 True 1 - 99
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/MakeModel.py in MakeModel(self, pressure, temperature, lowfreq, highfreq, angle, humidity, co2, o3, n2o, co, ch4, o2, no, so2, no2, nh3, hno3, lat, alt, wavegrid, resolution, save, libfile, vac2air)
469 if self.print_lblrtm_output:
--> 470 command = subprocess.check_call(cmd, shell=True)
471 if not self.print_lblrtm_output:
/usr/lib/python3.8/subprocess.py in check_call(*popenargs, **kwargs)
363 cmd = popenargs[0]
--> 364 raise CalledProcessError(retcode, cmd)
365 return 0
CalledProcessError: Command 'cd /home/mulaura/.TelFit/rundir1/;sh runlblrtm_v3.sh' returned non-zero exit status 127.
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-6-8f4bcd98a807> in <module>
132
133 # Perform the fit
--> 134 primary, model, R = fitter.Fit(data=order.copy(),
135 #Can give data here as well as separately like in the simpler fit example
136 resolution_fit_mode="gauss",
/usr/local/lib/python3.8/dist-packages/TelluricFitter.py in Fit(self, data, resolution_fit_mode, fit_primary, return_resolution, adjust_wave, continuum_fit_order, wavelength_fit_order, air_wave, fit_source, source_fcn, source_args, source_kwargs)
522 bfgs_optdict = {'disp': 2, 'pgtol': 1e-8, 'epsilon': 1, 'approx_grad': True}
523 slsqp_optdict = {'disp': 2, 'eps': 1e-1}
--> 524 output = leastsq(self.FitErrorFunction, fitpars, full_output=True, epsfcn=1e-1)
525
526 fitpars = output[0]
~/.local/lib/python3.8/site-packages/scipy/optimize/_minpack_py.py in leastsq(func, x0, args, Dfun, full_output, col_deriv, ftol, xtol, gtol, maxfev, epsfcn, factor, diag)
408 if not isinstance(args, tuple):
409 args = (args,)
--> 410 shape, dtype = _check_func('leastsq', 'func', func, x0, args, n)
411 m = shape[0]
412
~/.local/lib/python3.8/site-packages/scipy/optimize/_minpack_py.py in _check_func(checker, argname, thefunc, x0, args, numinputs, output_shape)
22 def _check_func(checker, argname, thefunc, x0, args, numinputs,
23 output_shape=None):
---> 24 res = atleast_1d(thefunc(*((x0[:numinputs],) + args)))
25 if (output_shape is not None) and (shape(res) != output_shape):
26 if (output_shape[0] != 1):
/usr/local/lib/python3.8/dist-packages/TelluricFitter.py in FitErrorFunction(self, fitpars)
569 """
570 if self.return_resolution:
--> 571 model, resolution = self.GenerateModel(fitpars, return_resolution=True)
572 else:
573 model = self.GenerateModel(fitpars)
/usr/local/lib/python3.8/dist-packages/TelluricFitter.py in GenerateModel(self, pars, nofit, separate_source, return_resolution, broaden, model, air_wave)
674 #Generate the model:
675 if model is None:
--> 676 model = self.Modeler.MakeModel(pressure, temperature, wavenum_start, wavenum_end, angle, h2o, co2, o3, n2o, co,
677 ch4, o2, no, so2, no2, nh3, hno3, lat=lat, alt=alt, wavegrid=None,
678 resolution=None, vac2air=air_wave_overwrite)
/usr/local/lib/python3.8/dist-packages/MakeModel.py in MakeModel(self, pressure, temperature, lowfreq, highfreq, angle, humidity, co2, o3, n2o, co, ch4, o2, no, so2, no2, nh3, hno3, lat, alt, wavegrid, resolution, save, libfile, vac2air)
473
474 except subprocess.CalledProcessError:
--> 475 raise subprocess.CalledProcessError("Error: Command '{}' failed in directory {}".format(cmd, TelluricModelingDir))
476
477 #Read in TAPE12, which is the output of LBLRTM
TypeError: __init__() missing 1 required positional argument: 'cmd'
Do you know a solution for that?
Kind regards, Laura
That looks like LBLRTM itself failed. Those are always super obscure since LBLRTM doesn't have great error message and is hard to debug. You can try running cd /home/mulaura/.TelFit/rundir1/;sh runlblrtm_v3.sh
directly to see if you can get the error that LBLRTM is indicating.
It has been a long time, but I think I remember things like that usually come down to trying to create a model with some crazy parameter (temperature = 10,000 or something). So you could also try to debug and see what the inputs to MakeModel or LBLRTM are.