Skip to content

Commit

Permalink
Bug fix in dataset serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
cpiker committed Aug 29, 2024
1 parent a32b458 commit bd7028d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
4 changes: 1 addition & 3 deletions das2/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,9 +1706,7 @@ DasErrCode DasIO_writeData(DasIO* pThis, DasDesc* pDesc, int iPktId)
/* May print many packets */

DasDs* pDs = (DasDs*)pDesc;

PktDesc* pPktDesc = (PktDesc*)pDesc;
if(! pPktDesc->bSentHdr)
if(! pDs->bSentHdr)
return das_error(DASERR_IO, "Send packet header ID %02d first", iPktId);

ptrdiff_t iIdx0 = 0;
Expand Down
31 changes: 22 additions & 9 deletions utilities/das3_spice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,27 @@ DasErrCode onDataSet(DasStream* pSdIn, int iPktId, DasDs* pDsIn, void* pUser)
/* ************************************************************************ */
/* Data output */

DasErrCode _dm2et(double* pOutput, const das_datum* pInput)
double _dm2et(const das_datum* pInput)
{
if(pInput->vt == vtTime)
return Units_convertFromDt(UNIT_ET2000, (const das_time*)pInput);

return Units_convertTo(UNIT_ET2000, das_datum_toDbl(pInput), pInput->units);
double rEt = 0.0;
if(pInput->vt == vtTime){
rEt = Units_convertFromDt(UNIT_ET2000, (const das_time*)pInput);
#ifndef NDEBUG
/* Check utc conversions */
char sBuf[32] = {'\0'};
dt_isoc(sBuf, 31, (const das_time*)pInput, 9);
double rCheck;
utc2et_c(sBuf, &rCheck);
if(fabs(rCheck - rEt) > 0.001){
das_error(PERR, "Debug check on spice time conversions failed");
return -1*60*60*24*50.0;
}
#endif
}
else
rEt = Units_convertTo(UNIT_ET2000, das_datum_toDbl(pInput), pInput->units);

return rEt;
}

/* We want the input dataset here because we need to know how many provided
Expand Down Expand Up @@ -1120,8 +1135,7 @@ DasErrCode _writeLocation(DasDs* pDsIn, XCalc* pCalc)
for(; !iter.done; das_uniq_iter_next(&iter)){

DasVar_get(pCalc->pTime, iter.index, &dm);
if(!_dm2et(&rEt, &dm))
return das_error(PERR, "Conversion of datum to ephemeris time failed");
rEt = _dm2et(&dm);

spkezp_c(
pReq->nBodyId, rEt, pReq->aOutFrame, "NONE", pReq->nOutCenter, aRecOut, &rLt
Expand Down Expand Up @@ -1219,8 +1233,7 @@ DasErrCode _writeRotation(DasDs* pDsIn, XCalc* pCalc)

DasVar_get(pCalc->pTime, iter.index, &dm);

if(!_dm2et(&rEt, &dm))
return das_error(PERR, "Conversion of datum to ephemeris time failed");
rEt = _dm2et(&dm);

pxform_c(pReq->aInFrame, pReq->aOutFrame, rEt, mRot); /* Get rot matrix */

Expand Down

0 comments on commit bd7028d

Please sign in to comment.