Code Monkey home page Code Monkey logo

Comments (17)

karllark avatar karllark commented on June 5, 2024

@alexmaragko : have you installed pahfit? This is now needed to get the run_pahfit command installed on your system. Check out the install instructions at:
https://pahfit.readthedocs.io/en/latest/install.html

I think this will solve the problem, but am not sure. Please try and tell me. :-)

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

@karllark Yes I have installed pahfit.

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

I will modify the code a bit to get the units in and make some runs for Monday's telecon though. :)

from pahfit.

karllark avatar karllark commented on June 5, 2024

Can you post the output error message? I don't understand why it doesn't work if you have installed it.

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

This is the output for M101_Nucleus_irs.ipac:
Traceback (most recent call last):
File "/usr/local/bin/run_pahfit", line 4, in
import('pkg_resources').run_script('pahfit==2.0.dev88', 'run_pahfit')
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 750, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 1527, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.5/dist-packages/pahfit-2.0.dev88-py3.5.egg/EGG-INFO/scripts/run_pahfit", line 88, in
pmodel = PAHFITBase(filename=packfile)
File "/usr/local/lib/python3.5/dist-packages/pahfit-2.0.dev88-py3.5.egg/pahfit/base.py", line 123, in init
param_info = self.read(filename, tformat=tformat)
File "/usr/local/lib/python3.5/dist-packages/pahfit-2.0.dev88-py3.5.egg/pahfit/base.py", line 373, in read
t = Table.read(filename, format=tformat)
File "/usr/local/lib/python3.5/dist-packages/astropy/table/table.py", line 2531, in read
out = io_registry.read(cls, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/astropy/io/registry.py", line 516, in read
reader = get_reader(format, cls)
File "/usr/local/lib/python3.5/dist-packages/astropy/io/registry.py", line 449, in get_reader
data_format, data_class.name, format_table_str))
astropy.io.registry.IORegistryError: No reader defined for format '5/dist-packages/pahfit-2' and class 'Table'.
The available formats are:
Format Read Write Auto-identify Deprecated


                  ascii  Yes   Yes            No           
           ascii.aastex  Yes   Yes            No           
            ascii.basic  Yes   Yes            No           
              ascii.cds  Yes    No            No           
 ascii.commented_header  Yes   Yes            No           
              ascii.csv  Yes   Yes            No           
          ascii.daophot  Yes    No            No           
             ascii.ecsv  Yes   Yes           Yes           
       ascii.fast_basic  Yes   Yes            No           

ascii.fast_commented_header Yes Yes No
ascii.fast_csv Yes Yes No
ascii.fast_no_header Yes Yes No
ascii.fast_rdb Yes Yes No
ascii.fast_tab Yes Yes No
ascii.fixed_width Yes Yes No
ascii.fixed_width_no_header Yes Yes No
ascii.fixed_width_two_line Yes Yes No
ascii.html Yes Yes Yes
ascii.ipac Yes Yes No
ascii.latex Yes Yes Yes
ascii.no_header Yes Yes No
ascii.rdb Yes Yes Yes
ascii.rst Yes Yes No
ascii.sextractor Yes No No
ascii.tab Yes Yes No
fits Yes Yes Yes
hdf5 Yes Yes Yes
votable Yes Yes Yes
aastex Yes Yes No Yes
cds Yes No No Yes
csv Yes Yes Yes Yes
daophot Yes No No Yes
html Yes Yes No Yes
ipac Yes Yes No Yes
latex Yes Yes No Yes
rdb Yes Yes No Yes

When I rename orion_bar_SWS_with7023shape.txt to orion_bar_SWS_with7023shape.ascii then the error is for the obs_spectrum['wavelength'] variable in the next line.

Traceback (most recent call last):
File "/usr/local/bin/run_pahfit", line 4, in
import('pkg_resources').run_script('pahfit==2.0.dev88', 'run_pahfit')
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 750, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 1527, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.5/dist-packages/pahfit-2.0.dev88-py3.5.egg/EGG-INFO/scripts/run_pahfit", line 66, in
obs_x = obs_spectrum['wavelength'].to(u.micron,
File "/usr/local/lib/python3.5/dist-packages/astropy/table/table.py", line 1222, in getitem
return self.columns[item]
File "/usr/local/lib/python3.5/dist-packages/astropy/table/table.py", line 106, in getitem
return OrderedDict.getitem(self, item)
KeyError: 'wavelength'

from pahfit.

karllark avatar karllark commented on June 5, 2024

Can you post what the command you are issuing on the command line is for the 1st part?

For the 2nd part, this is because the names of the columns are different than expected and the units are not defined in the file. You could add them, but probably need to update the format of the header to be like that for the M101 example. I did not do all this for the example data, just M101. But clearly should have.

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

run_pahfit M101_Nucleus_irs.ipac scipack_ExGal_SpitzerIRSSLLL.ipac

I have copied the spectrum files into a different directory than pahfit, and making the runs.

from pahfit.

karllark avatar karllark commented on June 5, 2024

For the first part, it looks like it is not parsing the string that is the filename correctly. The format table string it should be passing should be 'ipac' and it looks like it is passing '5/dist-packages/pahfit-2'. I don't understand.

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

Indeed changing the split index to -1 did the trick. I was able to make runs for both spectra without issues.

However, the txt extension is not recognized by the astropy reader and probably it should be renamed to ascii, or alternatively set a statement in the code to match txt with ascii extension internally.

Another thing to consider is how to set the units in the ascii input spectrum, so that the unit conversion part of the code applies to everything. I believe only ECSV format can accept units but not the ascii format. For ascii input spectra we could potentially require to have a second comment line with the units, and assign them in the code before the unit conversion.

Let me know what you think before I make a pull request.

from pahfit.

karllark avatar karllark commented on June 5, 2024

Another solution is to replace the ascii input spectrum with an ecsv or ipac format version that includes units.
I would create a small amount of code that reads in the ascii spectrum, adds units, then outputs as an ecsv file. Would be good to have alternate formats as part of the examples.

from pahfit.

karllark avatar karllark commented on June 5, 2024

Really glad changing the index to -1 worked!

from pahfit.

karllark avatar karllark commented on June 5, 2024

You can always make a pull request whenever and then update it as needed (just push the the branch used for the pull request).

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

Another solution is to replace the ascii input spectrum with an ecsv or ipac format version that includes units.
I would create a small amount of code that reads in the ascii spectrum, adds units, then outputs as an ecsv file. Would be good to have alternate formats as part of the examples.

You mean create and replace the orion_bar_SWS_with7023shape.txt spectrum with an ipac or ecsv equivalent to have it permanently in the data folder of pahfit?

from pahfit.

karllark avatar karllark commented on June 5, 2024

Yes.

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

Ok will do it first chance.

from pahfit.

alexmaragko avatar alexmaragko commented on June 5, 2024

I've turned orion_bar_SWS_with7023shape.txt into ipac format, so now pahfit can read it and fit it.

I've also added another spectrum in the data folder that @ThomasSYLai sent to me, and turned it into ecsv format in order to showcase one more input example.

In order to read ecsv files though, the Table.read format must be "ascii.ecsv". But if the input spectrum is e.g., "spectrum.ecsv" it will raise an error. So I've added a line to turn ecsv to ascii.ecsv.

Since we are currently sticking with input formats that have the units defined, ecsv will be the only "ascii"-type format that requires the special handling of ecsv --> ascii.ecsv, so we shouldn't be troubled to specify conversions for other ascii inputs.

from pahfit.

karllark avatar karllark commented on June 5, 2024

Great! Looking forward to the pull request for these changes!

from pahfit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.