peak.assignDimensions handling PIDs?

Hi,

We’re trying to use peak.assignDimensions feeding it a list of axis codes and a list of nmrAtoms as their PIDs as strings which it claims to handle. We’re getting errors like

File /local/u8/usrlocal/ccpnmr3.2.0/src/python/ccpn/core/Peak.py:909, in Peak.assignDimensions(self, axisCodes, values)
    906 for axis, value in zip(axisCodes, values):
    907     # isotopeCode. if not defined, assign to the nmrAtoms from the spectrum isotopeCodes
    908     for na in value:
--> 909         if na.isotopeCode in [UnknownIsotopeCode, self._UNKNOWN_VALUE_STRING, None]:
    910             try:
    911                 isotopeCodes = self.spectrum.getByAxisCodes('isotopeCodes', [specAxisCodes.index(axis)])

AttributeError: 'str' object has no attribute 'isotopeCode'

We think this may be because although the method checks for strings, sequences or plain nmrAtoms it stores these in dimensionNmrAtoms and uses them to set the assignments via the self.dimensionNmrAtoms call but then doesn’t use them in the isotopeCode setting loop because it goes back to the “values” passed as input.

Is the Isotope checking loop even needed?

…actually if we try with a list of nmrAtoms rather than PIDs we hit a problem in almost the same place:

File /local/u8/usrlocal/ccpnmr3.2.0/src/python/ccpn/core/Peak.py:908, in Peak.assignDimensions(self, axisCodes, values)
    904 self.dimensionNmrAtoms = dimensionNmrAtoms
    906 for axis, value in zip(axisCodes, values):
    907     # isotopeCode. if not defined, assign to the nmrAtoms from the spectrum isotopeCodes
--> 908     for na in value:
    909         if na.isotopeCode in [UnknownIsotopeCode, self._UNKNOWN_VALUE_STRING, None]:
    910             try:

TypeError: 'NmrAtom' object is not iterable

apologies - it does work with nmrAtoms so long as the list is dimensioned correctly e.g.

     peak.assignDimensions(axisCodes, [[newNmrAtomH], [newNmrAtomN]])

worked for us for a 2D peak

1 Like

Yes, I’m afraid that assignment on the command line is not as straightforward as it should be. Designing some improved routines for this is on my ToDo list, but not at the top yet…

If you have suggestions for ways in which you would like to be able to make assignments on the command line, then do let me know.
One of the things I would definitely like, for example, is the ability to “append” assignments.

BTW - a couple of routines (associated with Peaks) that often come in handy when doing this sort of thing are getByDimensions or getByAxisCodes. Do familiarise yourself with these.

Vicky