Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about new input format #2

Open
ddkn opened this issue Dec 5, 2020 · 3 comments
Open

Question about new input format #2

ddkn opened this issue Dec 5, 2020 · 3 comments

Comments

@ddkn
Copy link

ddkn commented Dec 5, 2020

Hello,

I was scanning some of the xps modules on pypi and ran across this! We currently use CasaXPS in our lab/department and I wrote a tiny module for doing some post analysis of the xps peaks (xps module in python actually, serves my purposes anyway, needs some updates which was coming over the break).

We are using a ThermoFisher XPS setup, and I was curious if you would be interested in including the input files from that machine? I believe they are AVG or VAMAS, but I need to take a look and could work on a parser as well.

I can also do some porting as well as testing, I mainly run MacOS and OpenBSD.

Cheers,

@schachmett
Copy link
Owner

Hi,

sorry for the late answer, I need to sort out my github notifications.
I would be interested very much in including some more input formats. I think I have some VAMAS files lying around but never got around to figure out how they work. If you want to contribute, you could take a look at this part and expand it:

gxps/gxps/io.py

Lines 51 to 93 in ab65228

def parse_spectrum_file(fname):
"""Checks file extension and calls appropriate parsing method."""
specdicts = []
with open(fname, "r") as sfile:
firstline = sfile.readline()
if fname.split(".")[-1] == "txt":
if "Region" in firstline:
for specdict in parse_eistxt(fname):
specdicts.append(specdict)
if "[Info]" in firstline:
specdicts.append(parse_arpestxt(fname))
elif re.fullmatch(r"\d+\.?\d*,\d+\.?\d*\n", firstline):
specdicts.append(parse_simple_xy(fname, delimiter=","))
elif re.fullmatch(r"\d+\.?\d*\s\d+\.?\d*\n", firstline):
specdicts.append(parse_simple_xy(fname))
elif fname.split(".")[-1] == "xy":
if re.fullmatch(r"\d+\.?\d*,\d+\.?\d*\n", firstline):
delimiter = ","
else:
delimiter = None
specdicts.append(parse_simple_xy(fname, delimiter=delimiter))
if not specdicts:
raise ValueError("Could not parse file '{}'".format(fname))
return specdicts
def parse_simple_xy(fname, delimiter=None):
"""
Parses the most simple x, y file with no header.
"""
energy, intensity = np.genfromtxt(
fname,
delimiter=delimiter,
unpack=True
)
specdict = {
"filename": fname,
"energy": energy,
"intensity": intensity,
"energy_scale": "binding",
"name": "S XY",
"notes": "file {}".format(fname.split("/")[-1])
}
return specdict

I think that the output dictionary that parse_eis_txt and parse_simple_xy return are self-explanatory.

Did you get gxps running on MacOS or on BSD? I realize that I need to make some adjustments to the installation files anyway because the launcher will not install properly on Ubuntu 20.04 and because the Windows install seems to be way easier using WSL.

Thanks for the feedback and cheers

@ddkn
Copy link
Author

ddkn commented Dec 17, 2020

No worries, things are busy here. Once this semester is over, I can take a look at things. I have *.avg and *.vamas files floating around. I can start to see what is required for compilation, as windows isn't my main machine (but have one). I can at least test for MacOS High Sierra, might be easier to get FreeBSD going than OpenBSD as I have made ports for them already, but if we can just make a pip install work then that would make life easiest for all subsequent ports.

I would be pretty happy to get this working and maybe suggest using it as a tool for the xps class (possibly more debugging, haha), as it has a clean interface and not overload students with 100 buttons like casaXPS. They do start lectures next semester maybe late January or February, so even compiling on Mac would be ideal, then getting the vamas files working on my end.

Always exciting to see open source tools for science!

@schachmett
Copy link
Owner

Cool, implementing vamas would be nice.
A fellow PhD student in my group already got it running on Windows with WSL, but I did not have the time yet to reproduce and document it. I have no clue about BSD yet. What is usually needed to port to that?
The problem with the pip install right now is that it tries to put the launcher, icons and other data into ~/.local/share (XDG_DATA_DIR, maybe there is some equivalent on Mac?). I think pip is not designed to install an application like this and it might be easier to just put the data where the code is and only worry about the launcher and/or entry point.

Yes, right now there is a lot of bugs (I wrote down some in gxps.todo). But I would be very happy if this can be put to more productive use. The goal is indeed to keep the interface somewhat clear. I am starting to write my thesis and another paper at the moment, but I will try to put some time into this project again. Learned a bit more on programming since I started this. Thanks for the enthusiasm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants