I didn't see it working for any conversions which is what caused me to send the email rather than just patching it. Either it is a mistake or deliberate.
Tim
On Nov 23, 2010, at 22:21, David Berry <[log in to unmask]> wrote:
> Do all conversions (e.g. _double -> _integer, etc) handle bad values
> incorrectly, or is it just _integer -> _word ?
>
> David
>
>
> On 24 November 2010 00:03, Tim Jenness <[log in to unmask]> wrote:
>> Brian,
>>
>> I am perplexed. I have a HDS data structure looking like this:
>>
>> SMU_JIG_INDEX(60) <_INTEGER> *,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,
>> *,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*
>>
>> and I want to read it as a _WORD. Currently I can't do it because I get this error:
>>
>> !! Error converting from _INTEGER to _WORD
>> ! A total of 60 data conversion error(s) occurred.
>> ! DAT_MAP: Error mapping an HDS primitive: 'SMU_JIG_INDEX'
>> ! Application exit status DAT__CONER, Conversion error
>>
>> because the code to do the conversion in daucnv.c looks like this:
>>
>> case DAT__W:
>> {
>> _INTEGER *src = (_INTEGER *) imp->body;
>> _WORD *des = (_WORD *) exp->body;
>> for (n = 0; n < nval; n++)
>> {
>> des[n] = (_UWORD) src[n];
>> if (des[n] != src[n])
>> {
>> (*nbad)++;
>> des[n] = dat_gl_ndr[ DAT__W ].bad.W;
>> hds_gl_status = DAT__CONER;
>> }
>> }
>> break;
>>
>> What I don't understand is why the conversion code does not test for the bad value. Something like this:
>>
>> case DAT__W:
>> {
>> _INTEGER *src = (_INTEGER *) imp->body;
>> _WORD *des = (_WORD *) exp->body;
>> for (n = 0; n < nval; n++)
>> {
>> des[n] = (_WORD) src[n];
>> if (des[n] != src[n])
>> {
>> des[n] = dat_gl_ndr[ DAT__W ].bad.W;
>> if (src[n] != dat_gl_ndr[ DAT__I ].bad.I )
>> {
>> (*nbad)++;
>> hds_gl_status = DAT__CONER;
>> }
>> }
>> }
>>
>> Seems to fix the problem. It doesn't look like incoming bads are checked anywhere. If I have a _WORD array and I map as _INTEGER it seems that the bad values don't get retained as bad either. Can you explain the logic to me please? I'm prepared to jump in to fix these conversions (my main motivation being that I have shrunk some of our data arrays in JCMT data from _INTEGER to _WORD but I still need to read old data files preferably with out having to special case them at the application layer).
>>
>> --
>> Tim Jenness
>> Joint Astronomy Centre
>>
|