Skip to content

Commit 040a96b

Browse files
committed
Better metadata for auto-generated vars
1 parent f67e200 commit 040a96b

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

utilities/das3_cdf.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void prnHelp()
158158
" summary -> CATDESC\n"
159159
" notes -> VAR_NOTES\n"
160160
" format -> FORMAT\n"
161-
" frame -> REFERENCE_FRAME\n"
161+
" frame -> COORD_FRAME\n"
162162
" nominalMin,nominalMax -> LIMITS_NOMINAL_MIN,LIMITS_NOMINAL_MAX\n"
163163
" scaleMin,scaleMax -> SCALEMIN,SCALEMAX\n"
164164
" scaleType -> SCALETYP\n"
@@ -774,7 +774,7 @@ const char* DasProp_cdfName(const DasProp* pProp)
774774
if(strcmp(sName, "info" ) == 0) return "VAR_NOTES";
775775
if(strcmp(sName, "notes" ) == 0) return "VAR_NOTES";
776776

777-
if(strcmp(sName, "frame" ) == 0) return "REFERENCE_FRAME";
777+
if(strcmp(sName, "frame" ) == 0) return "COORD_FRAME";
778778

779779
if(strcmp(sName, "fill" ) == 0) return "FILLVAL";
780780
if(strcmp(sName, "format" ) == 0) return "FORMAT";
@@ -1431,8 +1431,12 @@ DasErrCode onStream(StreamDesc* pSd, void* pUser){
14311431
if(pDot != NULL) *pDot = '.'; /* Put our damn dot back */
14321432

14331433
if(pCtx->bIstp){
1434+
1435+
/* Let the caller handle this...
14341436
if(!DasDesc_has((DasDesc*)pSd, "Data_version"))
14351437
DasDesc_setInt((DasDesc*)pSd, "Data_version", 1);
1438+
*/
1439+
14361440
if(!DasDesc_has((DasDesc*)pSd, "Generation_date")){
14371441
das_time dt;
14381442
dt_now(&dt);
@@ -1889,9 +1893,10 @@ const char* DasVar_cdfName(
18891893
return sBuf;
18901894
}
18911895

1892-
/* No override: Try var cdfName property */
1893-
if( (sName = DasDesc_getStr((const DasDesc*)pVar, "cdfName")) != NULL){
1894-
strncpy(sBuf, sName, uBufLen - 1);
1896+
/* No override: Try var cdfName property for this variable specifcally */
1897+
const DasProp* pVarName = DasDesc_getLocal((const DasDesc*)pVar, "cdfName");
1898+
if( pVarName != NULL){
1899+
strncpy(sBuf, DasProp_value(pVarName), uBufLen - 1);
18951900
return sBuf;
18961901
}
18971902

@@ -1903,7 +1908,7 @@ const char* DasVar_cdfName(
19031908
if((pVar == pPtVar) || (pVar == pRefVar) )
19041909
strncpy(sBuf, "Epoch", uBufLen - 1);
19051910
else if(pVar == DasDim_getVar(pDim, DASVAR_OFFSET))
1906-
strncpy(sBuf, "timeOffset", uBufLen - 1);
1911+
strncpy(sBuf, "EpochOffset", uBufLen - 1);
19071912

19081913
return sBuf;
19091914
}
@@ -1914,9 +1919,9 @@ const char* DasVar_cdfName(
19141919

19151920
if( (pVar == pPtVar)||(pVar == pRefVar)){
19161921
if(pDimName)
1917-
snprintf(sBuf, uBufLen - 1, "%s", DasProp_value(pDimName));
1922+
strncpy(sBuf, DasProp_value(pDimName), uBufLen - 1);
19181923
else
1919-
snprintf(sBuf, uBufLen - 1, "%s", DasDim_id(pDim));
1924+
strncpy(sBuf, DasDim_id(pDim), uBufLen - 1);
19201925
}
19211926
else{
19221927

@@ -2426,7 +2431,7 @@ DasErrCode writeVarProps(
24262431
if( (nRet = makeCompLabels(pCtx, pDim, pVar)) != DAS_OKAY)
24272432
return nRet;
24282433
if(DasDim_getFrame(pDim) != NULL)
2429-
writeVarStrAttr(pCtx, DasVar_cdfId(pVar), "REFERENCE_FRAME", DasDim_getFrame(pDim));
2434+
writeVarStrAttr(pCtx, DasVar_cdfId(pVar), "COORD_FRAME", DasDim_getFrame(pDim));
24302435
}
24312436

24322437
/* Copy down PhyDim properties to variables since CDF has no concept

utilities/das3_spice.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,11 @@ int _addLocInfo(DasDim* pDim, const XReq* pReq)
856856
if(nRet) return nRet;
857857

858858
nRet = DasDesc_setStr((DasDesc*)pDim, "notes", das_compsys_desc(pReq->uOutSystem));
859+
if(nRet) return nRet;
860+
861+
/* make skteditor shut up */
862+
nRet = DasDesc_setStr((DasDesc*)pDim, "format", "%.4e");
863+
if(nRet) return nRet;
859864

860865
return nRet;
861866
}
@@ -916,6 +921,11 @@ DasErrCode _addLocation(
916921

917922
/* Add record dependent, or record independent rotation vector variable */
918923

924+
const char* g_pRngProps[] = {
925+
"scaleMin", "scaleMax", "validMin", "validMax", "warnMin", "warnMax",
926+
"nominalMin", "nominalMax", ""
927+
};
928+
919929
DasErrCode _addRotation(XCalc* pCalc, const char* sAnonFrame, DasDs* pDsOut)
920930
{
921931
ptrdiff_t aDsShape[DASIDX_MAX] = DASIDX_INIT_UNUSED;
@@ -1059,7 +1069,13 @@ DasErrCode _addRotation(XCalc* pCalc, const char* sAnonFrame, DasDs* pDsOut)
10591069

10601070
/* Copy over the properties, and change a few */
10611071
DasDesc_copyIn((DasDesc*)pDimOut, (const DasDesc*)pDimIn);
1062-
DasDesc_setStr((DasDesc*)pDimOut, "FRAME", pReq->aOutFrame);
1072+
DasDesc_setStr((DasDesc*)pDimOut, "COORD_FRAME", pReq->aOutFrame);
1073+
DasDesc_setStr((DasDesc*)pDimOut, "COORD_SYS", das_compsys_str(pReq->uOutSystem));
1074+
1075+
/* The previous min/max probably no longer apply, strip them */
1076+
for(int i = 0; g_pRngProps[i][0] != '\0'; ++i){
1077+
DasDesc_remove((DasDesc*)pDimOut, g_pRngProps[i]);
1078+
}
10631079

10641080
/* update the cdfName property if that's found */
10651081
char sBuf[128] = {'\0'};

0 commit comments

Comments
 (0)