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

problem accessing values - nxvalue and nxlinks #74

Open
pquinn-dls opened this issue Mar 7, 2019 · 9 comments
Open

problem accessing values - nxvalue and nxlinks #74

pquinn-dls opened this issue Mar 7, 2019 · 9 comments

Comments

@pquinn-dls
Copy link

Hi,

I'm using a nexus file with links to external files.....
The file has "entry" - > which is processed data in the file and "raw_entry" which points to an external file.

If I try and access the external file via:

fin["raw_entry/instrument/detectors/xreye_x"].nxvalue

this works but...

fin["raw_entry"]["instrument"]["detectors"]["xreye_x"].nxvalue fails...

C:\ProgramData\Anaconda3\lib\site-packages\nexusformat\nexus\tree.py in nxvalue(self)
2711 If unmodified values are required, use the 'nxdata' property.
2712 """
-> 2713 _value = self.nxdata
2714 if _value is None:
2715 return None

C:\ProgramData\Anaconda3\lib\site-packages\nexusformat\nexus\tree.py in getattr(self, name)
4087 return self.attrs[name]
4088 else:
-> 4089 raise NeXusError("'"+name+"' not in "+self.nxpath)
4090
4091 def getitem(self, key):

NeXusError: 'nxdata' not in /raw_entry/instrument/detectors/xreye_x

Doing the same thing with "entry" seems fine so it seems to be related to the external file or nxlink ?

Paul

@rayosborn
Copy link
Contributor

That is puzzling. In principle both point to the same object. I have two questions that might help clarify the issue for me.

  1. What happens if you substitute 'nxdata' for 'nxvalue' in the two versions of the reference?
  2. Which item in the path is the external link? Is it 'xreye_x' or one of the enclosing groups?

@pquinn-dls
Copy link
Author

/raw_entry/instrument/detectors/xreye_x is all in an external file.
I'm not sure if I've quite got to the bottom of the bug.....

If I try...
fin["/raw_entry/instrument/detectors/xreye_z"].nxvalue

the first time I call this I get the nxdata error as above but
the second time I call it I get the value e.g. 40.0 and it returns the value from then on.
I've tried a few entries and can replicate this behaviour with the first call failing.

@rayosborn
Copy link
Contributor

The API caches the value once it's been read, and won't try to read it from the file again. I will try to replicate this with some dummy data.

@rayosborn
Copy link
Contributor

I've tried to reproduce the issue, but I seem to be able to access values embedded in linked groups using both reference patterns. I should have asked what version of the nexusformat API you are using. Just type 'nxversion' in the IPython shell. If it's a recent version, then I might have to look at the file itself if there is a way for me to access it.

@pquinn-dls
Copy link
Author

Hi,

nx.nxversion is 0.4.18

I've put some example files onto our anonymous ftp:
ftp://ftpanon.diamond.ac.uk/I14/ray/

Apologies for the size - 1Gb I couldn't find a smaller set but thought it was also worth replicating the structure.
And a nexus_read notebook demo

@rayosborn
Copy link
Contributor

I'll have a look when I'm back at work on Monday.

@pquinn-dls
Copy link
Author

Hi,
Did you have any luck re-producing this ?

@rayosborn
Copy link
Contributor

I have downloaded the files, but I can't see inside the 'raw_entry' link because it is an absolute file reference, and I can't create a /dis directory on my laptop. I can't check it today, but I should be able to copy it to a linux server tomorrow where I can put the 'dis' directory at root level.

@pquinn-dls
Copy link
Author

It will work on windows (I'm running on windows)
You need to recreate the folder structure in a root drive (the folder structure in the ftp was copied from a folder on my windows laptop)

D:\dls\i14....etc..
and in the script
os.chdir("D:") is needed for python to look in D: for the folder structure and links.

Python can deal with the linux/ win naming differences and it reads the paths etc. correctly (I'm running python3).

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