您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ wcserr_set函数代码示例

51自学网 2021-06-03 09:53:54
  C++
这篇教程C++ wcserr_set函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中wcserr_set函数的典型用法代码示例。如果您正苦于以下问题:C++ wcserr_set函数的具体用法?C++ wcserr_set怎么用?C++ wcserr_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了wcserr_set函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: unitfix

int unitfix(int ctrl, struct wcsprm *wcs){  int  i, k, status = FIXERR_NO_CHANGE;  char orig_unit[80], msg[WCSERR_MSG_LENGTH];  const char *function = "unitfix";  struct wcserr **err;  if (wcs == 0x0) return FIXERR_NULL_POINTER;  err = &(wcs->err);  strcpy(msg, "Changed units: ");  for (i = 0; i < wcs->naxis; i++) {    strncpy(orig_unit, wcs->cunit[i], 80);    if (wcsutrne(ctrl, wcs->cunit[i], &(wcs->err)) == 0) {      k = strlen(msg);      sprintf(msg+k, "'%s' -> '%s', ", orig_unit, wcs->cunit[i]);      status = FIXERR_UNITS_ALIAS;    }  }  if (status == FIXERR_UNITS_ALIAS) {    k = strlen(msg) - 2;    msg[k] = '/0';    wcserr_set(WCSERR_SET(FIXERR_UNITS_ALIAS), msg);    status = FIXERR_SUCCESS;  }  return status;}
开发者ID:MQQ,项目名称:astropy,代码行数:31,


示例2: lindist

int lindist(int sequence, struct linprm *lin, struct disprm *dis, int ndpmax){  static const char *function = "lindist";  int status;  struct wcserr **err;  if (lin == 0x0) return LINERR_NULL_POINTER;  err = &(lin->err);  if (sequence == 1) {    if (lin->m_dispre) {      disfree(lin->m_dispre);      free(lin->m_dispre);    }    lin->dispre   = dis;    lin->m_flag   = LINSET;    lin->m_dispre = dis;  } else if (sequence == 2) {    if (lin->m_disseq) {      disfree(lin->m_disseq);      free(lin->m_disseq);    }    lin->disseq   = dis;    lin->m_flag   = LINSET;    lin->m_disseq = dis;  } else {    return wcserr_set(WCSERR_SET(LINERR_DISTORT_INIT),      "Invalid sequence (%d)", sequence);  }  if (dis) {    if ((status = disinit(1, lin->naxis, dis, ndpmax))) {      return wcserr_set(LIN_ERRMSG(lin_diserr[status]));    }  }  return 0;}
开发者ID:SaraOgaz,项目名称:astropy,代码行数:44,


示例3: tabcpy

int tabcpy(int alloc, const struct tabprm *tabsrc, struct tabprm *tabdst){    static const char *function = "tabcpy";    int k, m, M, n, N, status;    double *dstp, *srcp;    struct wcserr **err;    if (tabsrc == 0x0) return TABERR_NULL_POINTER;    if (tabdst == 0x0) return TABERR_NULL_POINTER;    err = &(tabdst->err);    M = tabsrc->M;    if (M <= 0) {        return wcserr_set(WCSERR_SET(TABERR_BAD_PARAMS),                          "M must be positive, got %d", M);    }    if ((status = tabini(alloc, M, tabsrc->K, tabdst))) {        return status;    }    N = M;    for (m = 0; m < M; m++) {        tabdst->map[m]   = tabsrc->map[m];        tabdst->crval[m] = tabsrc->crval[m];        N *= tabsrc->K[m];    }    for (m = 0; m < M; m++) {        if ((srcp = tabsrc->index[m])) {            dstp = tabdst->index[m];            for (k = 0; k < tabsrc->K[m]; k++) {                *(dstp++) = *(srcp++);            }        }    }    srcp = tabsrc->coord;    dstp = tabdst->coord;    for (n = 0; n < N; n++) {        *(dstp++) = *(srcp++);    }    return 0;}
开发者ID:jonathansick,项目名称:astropy,代码行数:47,


示例4: unitfix

int unitfix(int ctrl, struct wcsprm *wcs){  int  i, k, result, status = FIXERR_NO_CHANGE;  char orig_unit[80], msg[WCSERR_MSG_LENGTH], msgtmp[WCSERR_MSG_LENGTH];  const char *function = "unitfix";  struct wcserr **err;  if (wcs == 0x0) return FIXERR_NULL_POINTER;  err = &(wcs->err);  strncpy(msg, "Changed units: ", WCSERR_MSG_LENGTH);  for (i = 0; i < wcs->naxis; i++) {    strncpy(orig_unit, wcs->cunit[i], 80);    result = wcsutrne(ctrl, wcs->cunit[i], &(wcs->err));    if (result == 0 || result == 12) {      k = strlen(msg);      if (k < WCSERR_MSG_LENGTH-1) {        wcsutil_null_fill(80, orig_unit);        sprintf(msgtmp, "'%s' -> '%s', ", orig_unit, wcs->cunit[i]);        strncpy(msg+k, msgtmp, WCSERR_MSG_LENGTH-1-k);        status = FIXERR_UNITS_ALIAS;      }    }  }  if (status == FIXERR_UNITS_ALIAS) {    /* Chop off the trailing ", ". */    k = strlen(msg) - 2;    msg[k] = '/0';    wcserr_set(WCSERR_SET(FIXERR_UNITS_ALIAS), msg);    status = 0;  }  return status;}
开发者ID:Bhilhanan,项目名称:astropy,代码行数:38,


示例5: linset

int linset(struct linprm *lin){  static const char *function = "linset";  int i, j, naxis, status;  double *pc, *piximg;  struct wcserr **err;  if (lin == 0x0) return LINERR_NULL_POINTER;  err = &(lin->err);  naxis = lin->naxis;  /* Check for a unit matrix. */  lin->unity = 1;  pc = lin->pc;  for (i = 0; i < naxis; i++) {    for (j = 0; j < naxis; j++) {      if (j == i) {        if (*(pc++) != 1.0) {          lin->unity = 0;          break;        }      } else {        if (*(pc++) != 0.0) {          lin->unity = 0;          break;        }      }    }  }  if (lin->unity) {    if (lin->flag == LINSET) {      /* Free memory that may have been allocated previously. */      if (lin->piximg) free(lin->piximg);      if (lin->imgpix) free(lin->imgpix);    }    lin->piximg  = 0x0;    lin->imgpix  = 0x0;    lin->i_naxis = 0;    /* Check cdelt. */    for (i = 0; i < naxis; i++) {      if (lin->cdelt[i] == 0.0) {        return wcserr_set(LIN_ERRMSG(LINERR_SINGULAR_MTX));      }    }  } else {    if (lin->flag != LINSET || lin->i_naxis < naxis) {      if (lin->flag == LINSET) {        /* Free memory that may have been allocated previously. */        if (lin->piximg) free(lin->piximg);        if (lin->imgpix) free(lin->imgpix);      }      /* Allocate memory for internal arrays. */      if ((lin->piximg = calloc(naxis*naxis, sizeof(double))) == 0x0) {        return wcserr_set(LIN_ERRMSG(LINERR_MEMORY));      }      if ((lin->imgpix = calloc(naxis*naxis, sizeof(double))) == 0x0) {        free(lin->piximg);        return wcserr_set(LIN_ERRMSG(LINERR_MEMORY));      }      lin->i_naxis = naxis;    }    /* Compute the pixel-to-image transformation matrix. */    pc     = lin->pc;    piximg = lin->piximg;    for (i = 0; i < naxis; i++) {      for (j = 0; j < naxis; j++) {        if (lin->disseq == 0x0) {          /* No sequent distortions, incorporate cdelt into piximg. */          *(piximg++) = lin->cdelt[i] * (*(pc++));        } else {          *(piximg++) = *(pc++);        }      }    }    /* Compute the image-to-pixel transformation matrix. */    if ((status = matinv(naxis, lin->piximg, lin->imgpix))) {      return wcserr_set(LIN_ERRMSG(status));    }  }  /* Set up the distortion functions. */  lin->affine = 1;  if (lin->dispre) {    if ((status = disset(lin->dispre))) {      return wcserr_set(LIN_ERRMSG(lin_diserr[status]));    }//.........这里部分代码省略.........
开发者ID:ninoc,项目名称:astropy,代码行数:101,


示例6: tabx2s

int tabx2s(    struct tabprm *tab,    int ncoord,    int nelem,    const double x[],    double world[],    int stat[]){    static const char *function = "tabx2s";    int i, iv, k, *Km, m, M, n, nv, offset, p1, status;    double *coord, *Psi, psi_m, upsilon, wgt;    register int *statp;    register const double *xp;    register double *wp;    struct wcserr **err;    if (tab == 0x0) return TABERR_NULL_POINTER;    err = &(tab->err);    /* Initialize if required. */    if (tab->flag != TABSET) {        if ((status = tabset(tab))) return status;    }    /* This is used a lot. */    M = tab->M;    status = 0;    xp = x;    wp = world;    statp = stat;    for (n = 0; n < ncoord; n++) {        /* Determine the indexes. */        Km = tab->K;        for (m = 0; m < M; m++, Km++) {            /* N.B. psi_m and Upsilon_m are 1-relative FITS indexes. */            i = tab->map[m];            psi_m = *(xp+i) + tab->crval[m];            Psi = tab->index[m];            if (Psi == 0x0) {                /* Default indexing is simple. */                upsilon = psi_m;            } else {                /* To ease confusion, decrement Psi so that we can use 1-relative                   C array indexing to match the 1-relative FITS indexing. */                Psi--;                if (*Km == 1) {                    /* Index vector is degenerate. */                    if (Psi[1]-0.5 <= psi_m && psi_m <= Psi[1]+0.5) {                        upsilon = psi_m;                    } else {                        *statp = 1;                        status = wcserr_set(TAB_ERRMSG(TABERR_BAD_X));                        goto next;                    }                } else {                    /* Interpolate in the indexing vector. */                    if (tab->sense[m] == 1) {                        /* Monotonic increasing index values. */                        if (psi_m < Psi[1]) {                            if (Psi[1] - 0.5*(Psi[2]-Psi[1]) <= psi_m) {                                /* Allow minor extrapolation. */                                k = 1;                            } else {                                /* Index is out of range. */                                *statp = 1;                                status = wcserr_set(TAB_ERRMSG(TABERR_BAD_X));                                goto next;                            }                        } else if (Psi[*Km] < psi_m) {                            if (psi_m <= Psi[*Km] + 0.5*(Psi[*Km]-Psi[*Km-1])) {                                /* Allow minor extrapolation. */                                k = *Km - 1;                            } else {                                /* Index is out of range. */                                *statp = 1;                                status = wcserr_set(TAB_ERRMSG(TABERR_BAD_X));                                goto next;                            }                        } else {                            for (k = 1; k < *Km; k++) {                                if (psi_m < Psi[k]) {                                    continue;                                }                                if (Psi[k] == psi_m && psi_m < Psi[k+1]) {                                    break;                                }                                if (Psi[k] < psi_m && psi_m <= Psi[k+1]) {                                    break;                                }//.........这里部分代码省略.........
开发者ID:jonathansick,项目名称:astropy,代码行数:101,


示例7: lincpy

int lincpy(int alloc, const struct linprm *linsrc, struct linprm *lindst){  static const char *function = "lincpy";  int i, j, naxis, status;  const double *srcp;  double *dstp;  struct wcserr **err;  if (linsrc == 0x0) return LINERR_NULL_POINTER;  if (lindst == 0x0) return LINERR_NULL_POINTER;  err = &(lindst->err);  naxis = linsrc->naxis;  if (naxis < 1) {    return wcserr_set(WCSERR_SET(LINERR_MEMORY),      "naxis must be positive (got %d)", naxis);  }  if ((status = linini(alloc, naxis, lindst))) {    return status;  }  srcp = linsrc->crpix;  dstp = lindst->crpix;  for (j = 0; j < naxis; j++) {    *(dstp++) = *(srcp++);  }  srcp = linsrc->pc;  dstp = lindst->pc;  for (i = 0; i < naxis; i++) {    for (j = 0; j < naxis; j++) {      *(dstp++) = *(srcp++);    }  }  srcp = linsrc->cdelt;  dstp = lindst->cdelt;  for (i = 0; i < naxis; i++) {    *(dstp++) = *(srcp++);  }  if (linsrc->dispre) {    if (!lindst->dispre) {      if ((lindst->dispre = calloc(1, sizeof(struct disprm))) == 0x0) {        return wcserr_set(LIN_ERRMSG(LINERR_MEMORY));      }      lindst->m_dispre = lindst->dispre;    }    if ((status = discpy(alloc, linsrc->dispre, lindst->dispre))) {      status = wcserr_set(LIN_ERRMSG(lin_diserr[status]));      goto cleanup;    }  }  if (linsrc->disseq) {    if (!lindst->disseq) {      if ((lindst->disseq = calloc(1, sizeof(struct disprm))) == 0x0) {        return wcserr_set(LIN_ERRMSG(LINERR_MEMORY));      }      lindst->m_disseq = lindst->disseq;    }    if ((status = discpy(alloc, linsrc->disseq, lindst->disseq))) {      status = wcserr_set(LIN_ERRMSG(lin_diserr[status]));      goto cleanup;    }  }cleanup:  if (status && (lindst->m_dispre || lindst->m_disseq)) {    if (lindst->dispre) free(lindst->dispre);    if (lindst->disseq) free(lindst->disseq);    lindst->dispre = 0x0;    lindst->disseq = 0x0;  }  return status;}
开发者ID:ninoc,项目名称:astropy,代码行数:84,


示例8: spcfix

int spcfix(struct wcsprm *wcs){  static const char *function = "spcfix";  char ctype[9], specsys[9];  int  i, status;  struct wcserr **err;  if (wcs == 0x0) return FIXERR_NULL_POINTER;  err = &(wcs->err);  for (i = 0; i < wcs->naxis; i++) {    /* Translate an AIPS-convention spectral type if present. */    status = spcaips(wcs->ctype[i], wcs->velref, ctype, specsys);    if (status == 0) {      /* An AIPS type was found but it may match what we already have. */      status = FIXERR_NO_CHANGE;      /* Was specsys translated? */      if (wcs->specsys[0] == '/0' && *specsys) {        strncpy(wcs->specsys, specsys, 9);        wcserr_set(WCSERR_SET(FIXERR_SPC_UPDATE),          "Changed SPECSYS to '%s'", specsys);        status = FIXERR_SUCCESS;      }      /* Was ctype translated?  Have to null-fill for comparing them. */      wcsutil_null_fill(9, wcs->ctype[i]);      if (strncmp(wcs->ctype[i], ctype, 9)) {        /* ctype was translated... */        if (status == FIXERR_SUCCESS) {          /* ...and specsys was also. */          wcserr_set(WCSERR_SET(FIXERR_SPC_UPDATE),            "Changed CTYPE%d from '%s' to '%s', and SPECSYS to '%s'",            i+1, wcs->ctype[i], ctype, wcs->specsys);        } else {          wcserr_set(WCSERR_SET(FIXERR_SPC_UPDATE),            "Changed CTYPE%d from '%s' to '%s'", i+1, wcs->ctype[i], ctype);          status = FIXERR_SUCCESS;        }        strncpy(wcs->ctype[i], ctype, 9);      }      /* Tidy up. */      if (status == FIXERR_SUCCESS) {        wcsutil_null_fill(72, wcs->ctype[i]);        wcsutil_null_fill(72, wcs->specsys);      }      /* No need to check for others, wcsset() will fail if so. */      return status;    } else if (status == SPCERR_BAD_SPEC_PARAMS) {      /* An AIPS spectral type was found but with invalid velref. */      return wcserr_set(WCSERR_SET(FIXERR_BAD_PARAM),        "Invalid parameter value: velref = %d", wcs->velref);    }  }  return FIXERR_NO_CHANGE;}
开发者ID:MQQ,项目名称:astropy,代码行数:63,


示例9: cylfix

int cylfix(const int naxis[], struct wcsprm *wcs){  static const char *function = "cylfix";  unsigned short icnr, indx[NMAX], ncnr;  int    j, k, stat[4], status;  double img[4][NMAX], lat, lng, phi[4], phi0, phimax, phimin, pix[4][NMAX],         *pixj, theta[4], theta0, world[4][NMAX], x, y;  struct wcserr **err;  if (naxis == 0x0) return FIXERR_NO_CHANGE;  if (wcs == 0x0) return FIXERR_NULL_POINTER;  err = &(wcs->err);  /* Initialize if required. */  if (wcs->flag != WCSSET) {    if ((status = wcsset(wcs))) return status;  }  /* Check that we have a cylindrical projection. */  if (wcs->cel.prj.category != CYLINDRICAL) return FIXERR_NO_CHANGE;  if (wcs->naxis < 2) return FIXERR_NO_CHANGE;  /* Compute the native longitude in each corner of the image. */  ncnr = 1 << wcs->naxis;  for (k = 0; k < NMAX; k++) {    indx[k] = 1 << k;  }  phimin =  1.0e99;  phimax = -1.0e99;  for (icnr = 0; icnr < ncnr;) {    /* Do four corners at a time. */    for (j = 0; j < 4; j++, icnr++) {      pixj = pix[j];      for (k = 0; k < wcs->naxis; k++) {        if (icnr & indx[k]) {          *(pixj++) = naxis[k] + 0.5;        } else {          *(pixj++) = 0.5;        }      }    }    if (!(status = wcsp2s(wcs, 4, NMAX, pix[0], img[0], phi, theta, world[0],                          stat))) {      for (j = 0; j < 4; j++) {        if (phi[j] < phimin) phimin = phi[j];        if (phi[j] > phimax) phimax = phi[j];      }    }  }  if (phimin > phimax) return status;  /* Any changes needed? */  if (phimin >= -180.0 && phimax <= 180.0) return FIXERR_NO_CHANGE;  /* Compute the new reference pixel coordinates. */  phi0 = (phimin + phimax) / 2.0;  theta0 = 0.0;  if ((status = prjs2x(&(wcs->cel.prj), 1, 1, 1, 1, &phi0, &theta0, &x, &y,                       stat))) {    if (status == PRJERR_BAD_PARAM) {      return wcserr_set(WCSFIX_ERRMSG(FIXERR_BAD_PARAM));    }    return wcserr_set(WCSFIX_ERRMSG(FIXERR_NO_REF_PIX_COORD));  }  for (k = 0; k < wcs->naxis; k++) {    img[0][k] = 0.0;  }  img[0][wcs->lng] = x;  img[0][wcs->lat] = y;  if ((status = linx2p(&(wcs->lin), 1, 0, img[0], pix[0]))) {    return wcserr_set(WCSFIX_ERRMSG(status));  }  /* Compute celestial coordinates at the new reference pixel. */  if ((status = wcsp2s(wcs, 1, 0, pix[0], img[0], phi, theta, world[0],                       stat))) {    if (wcs->err->status == WCSERR_BAD_PIX) {      wcs->err->status = FIXERR_NO_REF_PIX_COORD;    }    return wcs->err->status;  }  /* Compute native coordinates of the celestial pole. */  lng =  0.0;  lat = 90.0;  (void)sphs2x(wcs->cel.euler, 1, 1, 1, 1, &lng, &lat, phi, theta);//.........这里部分代码省略.........
开发者ID:MQQ,项目名称:astropy,代码行数:101,


示例10: linx2p

int linx2p(  struct linprm *lin,  int ncoord,  int nelem,  const double imgcrd[],  double pixcrd[]){  static const char *function = "linx2p";  int i, j, k, n, ndbl, nelemn, status;  register const double *img;  register double *imgpix, *pix, *tmp;  struct wcserr **err;  /* Initialize. */  if (lin == 0x0) return LINERR_NULL_POINTER;  err = &(lin->err);  if (lin->flag != LINSET) {    if ((status = linset(lin))) return status;  }  n = lin->naxis;  /* Convert intermediate world coordinates to pixel coordinates. */  img = imgcrd;  pix = pixcrd;  if (lin->simple) {    /* Handle the simplest and most common case with maximum efficiency. */    nelemn = nelem - n;    for (k = 0; k < ncoord; k++) {      for (j = 0; j < n; j++) {        *(pix++) = (*(img++) / lin->cdelt[j]) + lin->crpix[j];      }      img += nelemn;      pix += nelemn;    }  } else if (lin->affine) {    /* No distortions. */    nelemn = nelem - n;    for (k = 0; k < ncoord; k++) {      /* cdelt will have been incorporated into imgpix. */      imgpix = lin->imgpix;      for (j = 0; j < n; j++) {        *pix = 0.0;        for (i = 0; i < n; i++) {          *pix += *imgpix * img[i];          imgpix++;        }        *(pix++) += lin->crpix[j];      }      img += nelem;      pix += nelemn;    }  } else {    /* Distortions are present. */    ndbl = n * sizeof(double);    tmp  = lin->tmpcrd;    for (k = 0; k < ncoord; k++) {      if (lin->disseq) {        /* With sequent distortions, cdelt is not incorporated into imgpix. */        for (i = 0; i < n; i++) {          tmp[i] = img[i] / lin->cdelt[i];        }        if ((status = disx2p(lin->disseq, tmp, pix))) {          return wcserr_set(LIN_ERRMSG(lin_diserr[status]));        }        memcpy(tmp, pix, ndbl);      } else if (lin->unity) {        /* ...nor if the matrix is unity. */        for (i = 0; i < n; i++) {          tmp[i] = img[i] / lin->cdelt[i];        }      } else {        /* cdelt will have been incorporated into imgpix. */        memcpy(tmp, img, ndbl);      }      if (lin->unity) {        for (j = 0; j < n; j++) {          pix[j] = tmp[j] + lin->crpix[j];        }      } else {        imgpix = lin->imgpix;//.........这里部分代码省略.........
开发者ID:ninoc,项目名称:astropy,代码行数:101,


示例11: datfix

int datfix(struct wcsprm *wcs){  static const char *function = "datfix";  char orig_dateobs[72];  char ctmp[72], ctmp2[72];  char *dateobs;  int  day, dd, hour = 0, jd, minute = 0, month, msec, n4, year;  double mjdobs, sec = 0.0, t;  struct wcserr **err;  if (wcs == 0x0) return FIXERR_NULL_POINTER;  err = &(wcs->err);  dateobs = wcs->dateobs;  strncpy(orig_dateobs, dateobs, 72);  if (dateobs[0] == '/0') {    if (undefined(wcs->mjdobs)) {     /* No date information was provided. */      return FIXERR_NO_CHANGE;    } else {      /* Calendar date from MJD. */      jd = 2400001 + (int)wcs->mjdobs;      n4 =  4*(jd + ((2*((4*jd - 17918)/146097)*3)/4 + 1)/2 - 37);      dd = 10*(((n4-237)%1461)/4) + 5;      year  = n4/1461 - 4712;      month = (2 + dd/306)%12 + 1;      day   = (dd%306)/10 + 1;      sprintf(dateobs, "%.4d-%.2d-%.2d", year, month, day);      /* Write time part only if non-zero. */      if ((t = wcs->mjdobs - (int)wcs->mjdobs) > 0.0) {        t *= 24.0;        hour = (int)t;        t = 60.0 * (t - hour);        minute = (int)t;        sec    = 60.0 * (t - minute);        /* Round to 1ms. */        dd = 60000*(60*hour + minute) + (int)(1000*(sec+0.0005));        hour = dd / 3600000;        dd -= 3600000 * hour;        minute = dd / 60000;        msec = dd - 60000 * minute;        sprintf(dateobs+10, "T%.2d:%.2d:%.2d", hour, minute, msec/1000);        /* Write fractions of a second only if non-zero. */        if (msec%1000) {          sprintf(dateobs+19, ".%.3d", msec%1000);        }      }    }  } else {    if (strlen(dateobs) < 8) {      /* Can't be a valid date. */      return wcserr_set(WCSERR_SET(FIXERR_BAD_PARAM),        "Invalid parameter value: date string too short '%s'", dateobs);    }    /* Identify the date format. */    if (dateobs[4] == '-' && dateobs[7] == '-') {      /* Standard year-2000 form: CCYY-MM-DD[Thh:mm:ss[.sss...]] */      if (sscanf(dateobs, "%4d-%2d-%2d", &year, &month, &day) < 3) {        return wcserr_set(WCSERR_SET(FIXERR_BAD_PARAM),          "Invalid parameter value: invalid date '%s'", dateobs);      }      if (dateobs[10] == 'T') {        if (parse_date(dateobs+11, &hour, &minute, &sec)) {          return wcserr_set(WCSERR_SET(FIXERR_BAD_PARAM),            "Invalid parameter value: invalid time '%s'", dateobs+11);        }      } else if (dateobs[10] == ' ') {        hour = 0;        minute = 0;        sec = 0.0;        if (parse_date(dateobs+11, &hour, &minute, &sec)) {          write_date(dateobs+10, hour, minute, sec);        } else {          dateobs[10] = 'T';        }      }    } else if (dateobs[4] == '/' && dateobs[7] == '/') {      /* Also allow CCYY/MM/DD[Thh:mm:ss[.sss...]] */      if (sscanf(dateobs, "%4d/%2d/%2d", &year, &month, &day) < 3) {        return wcserr_set(WCSERR_SET(FIXERR_BAD_PARAM),          "Invalid parameter value: invalid date '%s'", dateobs);      }      if (dateobs[10] == 'T') {        if (parse_date(dateobs+11, &hour, &minute, &sec)) {          return wcserr_set(WCSERR_SET(FIXERR_BAD_PARAM),            "Invalid parameter value: invalid time '%s'", dateobs+11);        }//.........这里部分代码省略.........
开发者ID:MQQ,项目名称:astropy,代码行数:101,


示例12: spcx2s

int spcx2s(  struct spcprm *spc,  int nx,  int sx,  int sspec,  const double x[],  double spec[],  int stat[]){  static const char *function = "spcx2s";  int statP2S, status = 0, statX2P;  double beta;  register int ix;  register int *statp;  register const double *xp;  register double *specp;  struct wcserr **err;  /* Initialize. */  if (spc == 0x0) return SPCERR_NULL_POINTER;  err = &(spc->err);  if (spc->flag == 0) {    if ((status = spcset(spc))) return status;  }  /* Convert intermediate world coordinate x to X. */  xp = x;  specp = spec;  statp = stat;  for (ix = 0; ix < nx; ix++, xp += sx, specp += sspec) {    *specp = spc->w[1] + (*xp)*spc->w[2];    *(statp++) = 0;  }  /* If X is the grism parameter then convert it to wavelength. */  if (spc->isGrism) {    specp = spec;    for (ix = 0; ix < nx; ix++, specp += sspec) {      beta = atand(*specp) + spc->w[3];      *specp = (sind(beta) + spc->w[4]) * spc->w[5];    }  }  /* Apply the non-linear step of the algorithm chain to convert the    */  /* X-type spectral variable to P-type intermediate spectral variable. */  if (spc->spxX2P) {    if ((statX2P = spc->spxX2P(spc->w[0], nx, sspec, sspec, spec, spec,                               stat))) {      if (statX2P == SPXERR_BAD_INSPEC_COORD) {        status = SPCERR_BAD_X;      } else if (statX2P == SPXERR_BAD_SPEC_PARAMS) {        return wcserr_set(WCSERR_SET(SPCERR_BAD_SPEC_PARAMS),          "Invalid spectral parameters: Frequency or wavelength is 0");      } else {        return wcserr_set(SPC_ERRMSG(spc_spxerr[statX2P]));      }    }  }  /* Apply the linear step of the algorithm chain to convert P-type  */  /* intermediate spectral variable to the required S-type variable. */  if (spc->spxP2S) {    if ((statP2S = spc->spxP2S(spc->w[0], nx, sspec, sspec, spec, spec,                               stat))) {      if (statP2S == SPXERR_BAD_INSPEC_COORD) {        status = SPCERR_BAD_X;      } else if (statP2S == SPXERR_BAD_SPEC_PARAMS) {        return wcserr_set(WCSERR_SET(SPCERR_BAD_SPEC_PARAMS),          "Invalid spectral parameters: Frequency or wavelength is 0");      } else {        return wcserr_set(SPC_ERRMSG(spc_spxerr[statP2S]));      }    }  }  if (status) {    wcserr_set(SPC_ERRMSG(status));  }  return status;}
开发者ID:anizami,项目名称:astropy,代码行数:83,


示例13: spcs2x

int spcs2x(  struct spcprm *spc,  int nspec,  int sspec,  int sx,  const double spec[],  double x[],  int stat[]){  static const char *function = "spcs2x";  int statP2X, status = 0, statS2P;  double beta, s;  register int ispec;  register int *statp;  register const double *specp;  register double *xp;  struct wcserr **err;  /* Initialize. */  if (spc == 0x0) return SPCERR_NULL_POINTER;  err = &(spc->err);  if (spc->flag == 0) {    if ((status = spcset(spc))) return status;  }  /* Apply the linear step of the algorithm chain to convert the S-type */  /* spectral variable to P-type intermediate spectral variable.        */  if (spc->spxS2P) {    if ((statS2P = spc->spxS2P(spc->w[0], nspec, sspec, sx, spec, x, stat))) {      if (statS2P == SPXERR_BAD_INSPEC_COORD) {        status = SPCERR_BAD_SPEC;      } else if (statS2P == SPXERR_BAD_SPEC_PARAMS) {        return wcserr_set(WCSERR_SET(SPCERR_BAD_SPEC_PARAMS),          "Invalid spectral parameters: Frequency or wavelength is 0");      } else {        return wcserr_set(SPC_ERRMSG(spc_spxerr[statS2P]));      }    }  } else {    /* Just a copy. */    xp = x;    specp = spec;    statp = stat;    for (ispec = 0; ispec < nspec; ispec++, specp += sspec, xp += sx) {      *xp = *specp;      *(statp++) = 0;    }  }  /* Apply the non-linear step of the algorithm chain to convert P-type */  /* intermediate spectral variable to X-type spectral variable. */  if (spc->spxP2X) {    if ((statP2X = spc->spxP2X(spc->w[0], nspec, sx, sx, x, x, stat))) {      if (statP2X == SPCERR_BAD_SPEC) {        status = SPCERR_BAD_SPEC;      } else if (statP2X == SPXERR_BAD_SPEC_PARAMS) {        return wcserr_set(WCSERR_SET(SPCERR_BAD_SPEC_PARAMS),          "Invalid spectral parameters: Frequency or wavelength is 0");      } else {        return wcserr_set(SPC_ERRMSG(spc_spxerr[statP2X]));      }    }  }  if (spc->isGrism) {    /* Convert X-type spectral variable (wavelength) to grism parameter. */    xp = x;    statp = stat;    for (ispec = 0; ispec < nspec; ispec++, xp += sx, statp++) {      if (*statp) continue;      s = *xp/spc->w[5] - spc->w[4];      if (fabs(s) <= 1.0) {        beta = asind(s);        *xp = tand(beta - spc->w[3]);      } else {        *statp = 1;      }    }  }  /* Convert X-type spectral variable to intermediate world coordinate x. */  xp = x;  statp = stat;  for (ispec = 0; ispec < nspec; ispec++, xp += sx) {    if (*(statp++)) continue;    *xp -= spc->w[1];    *xp /= spc->w[2];  }  if (status) {    wcserr_set(SPC_ERRMSG(status));  }//.........这里部分代码省略.........
开发者ID:anizami,项目名称:astropy,代码行数:101,


示例14: spctrne

int spctrne(  const char ctypeS1[9],  double crvalS1,  double cdeltS1,  double restfrq,  double restwav,  char   ctypeS2[9],  double *crvalS2,  double *cdeltS2,  struct wcserr **err){  static const char *function = "spctrne";  char *cp, ptype1, ptype2, stype1[5], stype2[5], xtype1, xtype2;  int  restreq, status;  double crvalX, dS2dX, dXdS1;  if (restfrq == 0.0 && restwav == 0.0) {    /* If translating between two velocity-characteristic types, or between       two wave-characteristic types, then we may need to set a dummy rest       frequency or wavelength to perform the calculations. */    strncpy(stype1, ctypeS1, 4);    strncpy(stype2, ctypeS2, 4);    stype1[4] = stype2[4] = '/0';    if ((strstr("VRAD VOPT ZOPT VELO BETA", stype1) != 0x0) ==        (strstr("VRAD VOPT ZOPT VELO BETA", stype2) != 0x0)) {      restwav = 1.0;    }  }  if ((status = spcspxe(ctypeS1, crvalS1, restfrq, restwav, &ptype1, &xtype1,                        &restreq, &crvalX, &dXdS1, err))) {    return status;  }  /* Pad with blanks. */  ctypeS2[8] = '/0';  for (cp = ctypeS2; *cp; cp++);  while (cp < ctypeS2+8) *(cp++) = ' ';  if (strncmp(ctypeS2+5, "???", 3) == 0) {    /* Set the algorithm code if required. */    if (xtype1 == 'w') {      strcpy(ctypeS2+5, "GRI");    } else if (xtype1 == 'a') {      strcpy(ctypeS2+5, "GRA");    } else {      ctypeS2[5] = xtype1;      ctypeS2[6] = '2';    }  }  if ((status = spcxpse(ctypeS2, crvalX, restfrq, restwav, &ptype2, &xtype2,                        &restreq, crvalS2, &dS2dX, err))) {    return status;  }  /* Are the X-types compatible? */  if (xtype2 != xtype1) {    return wcserr_set(WCSERR_SET(SPCERR_BAD_SPEC_PARAMS),      "Incompatible X-types '%c' and '%c'", xtype1, xtype2);  }  if (ctypeS2[7] == '?') {    if (ptype2 == xtype2) {      strcpy(ctypeS2+4, "    ");    } else {      ctypeS2[7] = ptype2;    }  }  *cdeltS2 = dS2dX * dXdS1 * cdeltS1;  return 0;}
开发者ID:anizami,项目名称:astropy,代码行数:76,


示例15: spcset

int spcset(struct spcprm *spc){  static const char *function = "spcset";  char   ctype[9], ptype, xtype;  int    restreq, status;  double alpha, beta_r, crvalX, dn_r, dXdS, epsilon, G, m, lambda_r, n_r,         t, restfrq, restwav, theta;  struct wcserr **err;  if (spc == 0x0) return SPCERR_NULL_POINTER;  err = &(spc->err);  if (undefined(spc->crval)) {    return wcserr_set(WCSERR_SET(SPCERR_BAD_SPEC_PARAMS),      "Spectral crval is undefined");  }  memset((spc->type)+4, 0, 4);  spc->code[3] = '/0';  wcsutil_blank_fill(4, spc->type);  wcsutil_blank_fill(3, spc->code);  spc->w[0] = 0.0;  /* Analyse the spectral axis type. */  memset(ctype, 0, 9);  strncpy(ctype, spc->type, 4);  if (*(spc->code) != ' ') {    sprintf(ctype+4, "-%s", spc->code);  }  restfrq = spc->restfrq;  restwav = spc->restwav;  if ((status = spcspxe(ctype, spc->crval, restfrq, restwav, &ptype, &xtype,                        &restreq, &crvalX, &dXdS, &(spc->err)))) {    return status;  }  /* Satisfy rest frequency/wavelength requirements. */  if (restreq) {    if (restreq == 3 && restfrq == 0.0 && restwav == 0.0) {      /* VRAD-V2F, VOPT-V2W, and ZOPT-V2W require the rest frequency or */      /* wavelength for the S-P and P-X transformations but not for S-X */      /* so supply a phoney value. */      restwav = 1.0;    }    if (restfrq == 0.0) {      restfrq = C/restwav;    } else {      restwav = C/restfrq;    }    if (ptype == 'F') {      spc->w[0] = restfrq;    } else if (ptype != 'V') {      spc->w[0] = restwav;    } else {      if (xtype == 'F') {        spc->w[0] = restfrq;      } else {        spc->w[0] = restwav;      }    }  }  spc->w[1] = crvalX;  spc->w[2] = dXdS;  /* Set pointers-to-functions for the linear part of the transformation. */  if (ptype == 'F') {    if (strcmp(spc->type, "FREQ") == 0) {      /* Frequency. */      spc->flag = FREQ;      spc->spxP2S = 0x0;      spc->spxS2P = 0x0;    } else if (strcmp(spc->type, "AFRQ") == 0) {      /* Angular frequency. */      spc->flag = AFRQ;      spc->spxP2S = freqafrq;      spc->spxS2P = afrqfreq;    } else if (strcmp(spc->type, "ENER") == 0) {      /* Photon energy. */      spc->flag = ENER;      spc->spxP2S = freqener;      spc->spxS2P = enerfreq;    } else if (strcmp(spc->type, "WAVN") == 0) {      /* Wave number. */      spc->flag = WAVN;      spc->spxP2S = freqwavn;      spc->spxS2P = wavnfreq;    } else if (strcmp(spc->type, "VRAD") == 0) {      /* Radio velocity. */      spc->flag = VRAD;//.........这里部分代码省略.........
开发者ID:anizami,项目名称:astropy,代码行数:101,


示例16: sip_init

intsip_init(    sip_t* sip,    const unsigned int a_order, const double* a,    const unsigned int b_order, const double* b,    const unsigned int ap_order, const double* ap,    const unsigned int bp_order, const double* bp,    const double* crpix /* [2] */) {  unsigned int       a_size       = 0;  unsigned int       b_size       = 0;  unsigned int       ap_size      = 0;  unsigned int       bp_size      = 0;  unsigned int       scratch_size = 0;  int                status       = 0;  struct wcserr**    err          = NULL;  static const char *function     = "sip_init";  assert(sip != NULL);  sip_clear(sip);  err = &(sip->err);  /* We we have one of A/B or AP/BP, we must have both. */  if ((a == NULL) ^ (b == NULL)) {    return wcserr_set(      SIP_ERRMSG(WCSERR_BAD_COORD_TRANS),      "Both A and B SIP transform must be defined");  }  if ((ap == NULL) ^ (bp == NULL)) {    return wcserr_set(      SIP_ERRMSG(WCSERR_BAD_COORD_TRANS),      "Both AP and BP SIP transform must be defined");  }  if (a != NULL) {    sip->a_order = a_order;    a_size = (a_order + 1) * (a_order + 1) * sizeof(double);    sip->a = malloc(a_size);    if (sip->a == NULL) {      sip_free(sip);      status = wcserr_set(        SIP_ERRMSG(WCSERR_MEMORY), "Memory allocation failed");      goto exit;    }    memcpy(sip->a, a, a_size);    if (a_order > scratch_size) {      scratch_size = a_order;    }    sip->b_order = b_order;    b_size = (b_order + 1) * (b_order + 1) * sizeof(double);    sip->b = malloc(b_size);    if (sip->b == NULL) {      sip_free(sip);      status = wcserr_set(        SIP_ERRMSG(WCSERR_MEMORY), "Memory allocation failed");      goto exit;    }    memcpy(sip->b, b, b_size);    if (b_order > scratch_size) {      scratch_size = b_order;    }  }  if (ap != NULL) {    sip->ap_order = ap_order;    ap_size = (ap_order + 1) * (ap_order + 1) * sizeof(double);    sip->ap = malloc(ap_size);    if (sip->ap == NULL) {      sip_free(sip);      status = wcserr_set(        SIP_ERRMSG(WCSERR_MEMORY), "Memory allocation failed");      goto exit;    }    memcpy(sip->ap, ap, ap_size);    if (ap_order > scratch_size) {      scratch_size = ap_order;    }    sip->bp_order = bp_order;    bp_size = (bp_order + 1) * (bp_order + 1) * sizeof(double);    sip->bp = malloc(bp_size);    if (sip->bp == NULL) {      sip_free(sip);      status = wcserr_set(        SIP_ERRMSG(WCSERR_MEMORY), "Memory allocation failed");      goto exit;    }    memcpy(sip->bp, bp, bp_size);    if (bp_order > scratch_size) {      scratch_size = bp_order;    }  }  scratch_size = (scratch_size + 1) * sizeof(double);  sip->scratch = malloc(scratch_size);  if (sip->scratch == NULL) {    sip_free(sip);//.........这里部分代码省略.........
开发者ID:jhunkeler,项目名称:pywcs,代码行数:101,


示例17: pipeline_all_pixel2world

intpipeline_all_pixel2world(    pipeline_t* pipeline,    const unsigned int ncoord,    const unsigned int nelem,    const double* const pixcrd /* [ncoord][nelem] */,    double* world /* [ncoord][nelem] */) {  static const char* function = "pipeline_all_pixel2world";  const double*   wcs_input  = NULL;  double*         wcs_output = NULL;  int             has_det2im;  int             has_sip;  int             has_p4;  int             has_wcs;  int             status     = 1;  struct wcserr **err;  /* Temporary buffer for performing WCS calculations */  unsigned char*     buffer = NULL;  unsigned char*     mem = NULL;  /*@[email
C++ wcsftime函数代码示例
C++ wcsdup函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。