xmlNodePtr XLALInferenceStateVariables2VOTResource(LALInferenceRunState *const state, const char *name) { xmlNodePtr algNode=NULL; xmlNodePtr priorNode=NULL; xmlNodePtr resNode=NULL; /* Serialise various params to VOT Table nodes */ resNode=XLALCreateVOTResourceNode("lalinference:state",name,NULL); algNode=XLALInferenceVariablesArray2VOTTable(&(state->algorithmParams),1, "Algorithm Params"); if(algNode) { xmlNewProp(algNode, CAST_CONST_XMLCHAR("utype"), CAST_CONST_XMLCHAR("lalinference:state:algorithmparams")); xmlAddChild(resNode,algNode); } priorNode=XLALInferenceVariablesArray2VOTTable(&(state->priorArgs),1,"Prior Arguments"); if(priorNode){ xmlNewProp(priorNode, CAST_CONST_XMLCHAR("utype"), CAST_CONST_XMLCHAR("lalinference:state:priorparams")); xmlAddChild(resNode,priorNode); } return(resNode); }
/** * \brief Serializes a \c PulsarDopplerParams structure into a VOTable XML %node * * This function takes a \c PulsarDopplerParams structure and serializes it into a VOTable * \c RESOURCE %node identified by the given name. The returned \c xmlNode can then be * embedded into an existing %node hierarchy or turned into a full VOTable document. * * \param pdp [in] Pointer to the \c PulsarDopplerParams structure to be serialized * \param name [in] Unique identifier of this particular \c PulsarDopplerParams structure instance * * \return A pointer to a \c xmlNode that holds the VOTable fragment that represents * the \c PulsarDopplerParams structure. * In case of an error, a null-pointer is returned.\n * \b Important: the caller is responsible to free the allocated memory (when the * fragment isn't needed anymore) using \c xmlFreeNode. Alternatively, \c xmlFreeDoc * can be used later on when the returned fragment has been embedded in a XML document. * * \sa XLALCreateVOTParamNode * \sa XLALCreateVOTResourceNode * \sa XLALCreateVOTDocumentFromTree * * \author Oliver Bock\n * Albert-Einstein-Institute Hannover, Germany */ xmlNodePtr XLALPulsarDopplerParams2VOTNode(const PulsarDopplerParams *const pdp, const char *name) { /* set up local variables */ xmlNodePtr xmlParentNode = NULL; xmlNodePtr xmlChildNode = NULL; xmlNodePtr xmlChildNodeList = NULL; xmlNodePtr xmlCurrentChildNode = NULL; /* check and convert input parameters */ XLAL_CHECK_NULL ( pdp != NULL, XLAL_EINVAL ); CHAR Alpha[REAL8STR_MAXLEN] = {0}; if( snprintf(Alpha, REAL8STR_MAXLEN, "%g", pdp->Alpha) < 0) { XLALPrintError("Invalid input parameter: PulsarDopplerParams->Alpha\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } CHAR Delta[REAL8STR_MAXLEN] = {0}; if( snprintf(Delta, REAL8STR_MAXLEN, "%g", pdp->Delta) < 0) { XLALPrintError("Invalid input parameter: PulsarDopplerParams->Delta\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } CHAR argp[REAL8STR_MAXLEN] = {0}; if( snprintf(argp, REAL8STR_MAXLEN, "%g", pdp->argp) < 0) { XLALPrintError("Invalid input parameter: PulsarDopplerParams->argp\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } CHAR asini[REAL8STR_MAXLEN] = {0}; if( snprintf(asini, REAL8STR_MAXLEN, "%g", pdp->asini) < 0) { XLALPrintError("Invalid input parameter: PulsarDopplerParams->asini\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } CHAR ecc[REAL8STR_MAXLEN] = {0}; if( snprintf(ecc, REAL8STR_MAXLEN, "%g", pdp->ecc) < 0) { XLALPrintError("Invalid input parameter: PulsarDopplerParams->ecc\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } CHAR period[REAL8STR_MAXLEN] = {0}; if( snprintf(period, REAL8STR_MAXLEN, "%g", pdp->period) < 0) { XLALPrintError("Invalid input parameter: PulsarDopplerParams->period\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } if(!name || strlen(name) <= 0) { XLALPrintError("Invalid input parameter: name\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } /* ----- set up PARAM node (Alpha) */ xmlChildNode = XLALCreateVOTParamNode("Alpha", "rad", VOT_REAL8, NULL, Alpha); if(!xmlChildNode) { XLALPrintError("Couldn't create PARAM node: %s.Alpha\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* initialize child node list with first child */ xmlChildNodeList = xmlChildNode; xmlCurrentChildNode = xmlChildNodeList; /* ----- set up PARAM node (Delta) */ xmlChildNode = XLALCreateVOTParamNode("Delta", "rad", VOT_REAL8, NULL, Delta); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create PARAM node: %s.Delta\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; /* ----- set up PARAM node (fkdot) */ xmlChildNode = XLALPulsarSpins2VOTNode(&pdp->fkdot, "fkdot"); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create PARAM node: %s.fkdot\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; // ---------- handle binary-orbital parameters ---------- /* ----- set up PARAM node (argp) */ xmlChildNode = XLALCreateVOTParamNode("argp", "rad", VOT_REAL8, NULL, argp); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create PARAM node: %s.argp\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; /* ----- set up PARAM node (asini) */ xmlChildNode = XLALCreateVOTParamNode("asini", "s", VOT_REAL8, NULL, asini); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create PARAM node: %s.asini\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; /* ----- set up PARAM node (ecc) */ xmlChildNode = XLALCreateVOTParamNode("ecc", NULL, VOT_REAL8, NULL, ecc); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create PARAM node: %s.ecc\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; /* ----- set up PARAM node (period) */ xmlChildNode = XLALCreateVOTParamNode("period", "s", VOT_REAL8, NULL, period); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create PARAM node: %s.period\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; /* ----- set up RESOURCE node (refTime)*/ xmlChildNode = XLALLIGOTimeGPS2VOTNode(&pdp->refTime, "refTime" ); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create RESOURCE node: %s.refTime\n", name ); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; /* ----- set up RESOURCE node (tp)*/ xmlChildNode = XLALLIGOTimeGPS2VOTNode(&pdp->tp, "tp"); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create RESOURCE node: tp\n"); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as next sibling to child node list */ xmlCurrentChildNode->next = xmlChildNode; xmlCurrentChildNode = xmlCurrentChildNode->next; // ---------- END: binary-orbital parameters ---------- /* set up parent RESOURCE node*/ xmlParentNode = XLALCreateVOTResourceNode("PulsarDopplerParams", name, xmlChildNodeList); if(!xmlParentNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create RESOURCE node: %s\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* return RESOURCE node (needs to be xmlFreeNode'd or xmlFreeDoc'd by caller!!!) */ return xmlParentNode; } // XLALPulsarDopplerParams2VOTNode()
/** * \brief Serializes a \c LIGOTimeGPS structure into a VOTable XML %node * * This function takes a \c LIGOTimeGPS structure and serializes it into a VOTable * \c RESOURCE %node identified by the given name. The returned \c xmlNode can then be * embedded into an existing %node hierarchy or turned into a full VOTable document. * * \param ltg [in] Pointer to the \c LIGOTimeGPS structure to be serialized * \param name [in] Unique identifier of this particular \c LIGOTimeGPS structure instance * * \return A pointer to a \c xmlNode that holds the VOTable fragment that represents * the \c LIGOTimeGPS structure. * In case of an error, a null-pointer is returned.\n * \b Important: the caller is responsible to free the allocated memory (when the * fragment isn't needed anymore) using \c xmlFreeNode. Alternatively, \c xmlFreeDoc * can be used later on when the returned fragment has been embedded in a XML document. * * \sa XLALCreateVOTParamNode * \sa XLALCreateVOTResourceNode * \sa XLALCreateVOTDocumentFromTree * * \author Oliver Bock\n * Albert-Einstein-Institute Hannover, Germany */ xmlNodePtr XLALLIGOTimeGPS2VOTNode(const LIGOTimeGPS *const ltg, const char *name) { /* set up local variables */ xmlNodePtr xmlParentNode = NULL; xmlNodePtr xmlChildNode = NULL; xmlNodePtr xmlChildNodeList = NULL; CHAR gpsSecondsBuffer[INT4STR_MAXLEN] = {0}; CHAR gpsNanoSecondsBuffer[INT4STR_MAXLEN] = {0}; /* check and prepare input parameters */ if(!ltg || snprintf(gpsSecondsBuffer, INT4STR_MAXLEN, "%i", ltg->gpsSeconds) < 0) { XLALPrintError("Invalid input parameter: LIGOTimeGPS->gpsSeconds\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } if(!ltg || snprintf(gpsNanoSecondsBuffer, INT4STR_MAXLEN, "%i", ltg->gpsNanoSeconds) < 0) { XLALPrintError("Invalid input parameter: LIGOTimeGPS->gpsNanoSeconds\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } if(!name || strlen(name) <= 0) { XLALPrintError("Invalid input parameter: name\n"); XLAL_ERROR_NULL(XLAL_EINVAL); } /* set up RESOURCE node child (first PARAM) */ xmlChildNode = XLALCreateVOTParamNode("gpsSeconds", "s", VOT_INT4, NULL, gpsSecondsBuffer); if(!xmlChildNode) { XLALPrintError("Couldn't create PARAM node: , %s.gpsSeconds\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* initialize child node list with first child */ xmlChildNodeList = xmlChildNode; /* set up RESOURCE node child (second PARAM) */ xmlChildNode = XLALCreateVOTParamNode("gpsNanoSeconds", "ns", VOT_INT4, NULL, gpsNanoSecondsBuffer); if(!xmlChildNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create PARAM node: %s.gpsNanoSeconds\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* add child as first sibling to child node list */ xmlChildNodeList->next = xmlChildNode; /* set up RESOURCE node*/ xmlParentNode = XLALCreateVOTResourceNode("LIGOTimeGPS", name, xmlChildNodeList); if(!xmlParentNode) { /* clean up */ xmlFreeNodeList(xmlChildNodeList); XLALPrintError("Couldn't create RESOURCE node: %s\n", name); XLAL_ERROR_NULL(XLAL_EFAILED); } /* return RESOURCE node (needs to be xmlFreeNode'd or xmlFreeDoc'd by caller!!!) */ return xmlParentNode; }