DrSAR / SARlabpy

git clone git@pfeifer.phas.ubc.ca:SARlabpy (do not push to github, please)
http://code.SARlab.ca
Other
1 stars 0 forks source link

readRFshape screws up when it tries to read XYPOINTS #101

Closed andrewcyung closed 11 years ago

andrewcyung commented 11 years ago

Bruker shape files have a XYPOINTS field (for amplitude and phase of the shape) which has a nonstandard JCAMP format:

XYPOINTS= (XY..XY)

amp1, phase1 amp2, phase2

etc.

readJCAMP gets tripped up by the (XY..XY). It puts this string as the first item in the RFshape['XYPOINTS'] dictionary

Therefore when the following is executed:

# make a consecutive list of float values stored in the XYPOINTS field
XYlist = ' '.join(RFshape['XYPOINTS'].split(', ')).split()
RFshape['amp'] = [float(dummy) for dummy in XYlist[::2]]
RFshape['phase'] = [float(dummy) for dummy in XYlist[1::2]]

the RFshape['amp'] assignment fails on the first iteration because it is trying to convert "(XY..XY)" to a float.

One easy fix: just live with the wrong XYPOINTS definition, but start the iteration on the 2nd item of XYlist:

RFshape['amp'] = [float(dummy) for dummy in XYlist[1::2]]
RFshape['phase'] = [float(dummy) for dummy in XYlist[2::2]]
DrSAR commented 11 years ago

yeah - annoying. I think this is a clear violation of the JCAMP format, no? Should we try to catch this in readJCAMP or what would be the repercussions of using your fix? Length of amp and phase misjudged?

andrewcyung commented 11 years ago

I don’t think we should catch it in readJCAMP, since this is clearly a violation of the format for the other Bruker parameter files. Actually I think the array sizes are correct with my quick fix.

DrSAR commented 11 years ago

Sounds good. So this is only a change in readRFshape which is a wrapper for readJCAMP as applied to the shape files. Are you going to submit a commit with the bugfix or should I?

andrewcyung mailto:notifications@github.com 8 April, 2013 22:29

I don’t think we should catch it in readJCAMP, since this is clearly a violation of the format for the other Bruker parameter files. Actually I think the array sizes are correct with my quick fix.

— Reply to this email directly or view it on GitHub https://github.com/DrSAR/SARlabpy/issues/101#issuecomment-16094948.

andrewcyung mailto:notifications@github.com 8 April, 2013 22:12

Bruker shape files have a XYPOINTS field (for amplitude and phase of the shape) which has a nonstandard JCAMP format:

XYPOINTS= (XY..XY)

amp1, phase1 amp2, phase2

etc.

readJCAMP gets tripped up by the (XY..XY). It puts this string as the first item in the RFshape['XYPOINTS'] dictionary

Therefore when the following is executed:

# make a consecutive list of float values stored in the XYPOINTS field XYlist = ' '.join(RFshape['XYPOINTS'].split(', ')).split() RFshape['amp'] = [float(dummy) for dummy in XYlist[::2]] RFshape['phase'] = [float(dummy) for dummy in XYlist[1::2]]

the RFshape['amp'] assignment fails on the first iteration because it is trying to convert "(XY..XY)" to a float.

One easy fix: just live with the wrong XYPOINTS definition, but start the iteration on the 2nd item of XYlist:

RFshape['amp'] = [float(dummy) for dummy in XYlist[1::2]] RFshape['phase'] = [float(dummy) for dummy in XYlist[2::2]]

— Reply to this email directly or view it on GitHub https://github.com/DrSAR/SARlabpy/issues/101.

andrewcyung commented 11 years ago

Ummm... I think I did it. Can you see the iss101 branch?