IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 4, 2008, 10:08:33 PM (18 years ago)
Author:
Paul Price
Message:

Adding functions psFitsWriteImageCubeWithMask and psFitsUpdateImageCubeWithMask. psModules generally writes images as cubes, so need these to get the mask down into psFitsWriteImage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsImage.c

    r19383 r19384  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-09-05 07:51:09 $
     9 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2008-09-05 08:08:33 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    892892bool psFitsWriteImageCube(psFits *fits, psMetadata *header, const psArray *input, const char *extname)
    893893{
     894    return psFitsWriteImageCubeWithMask(fits, header, input, NULL, 0, extname);
     895}
     896
     897bool psFitsWriteImageCubeWithMask(psFits *fits, psMetadata *header, const psArray *input,
     898                                  const psArray *masks, psMaskType maskVal, const char *extname)
     899{
    894900    PS_ASSERT_FITS_NON_NULL(fits, false);
    895901    PS_ASSERT_FITS_WRITABLE(fits, false);
    896902    PS_ASSERT_ARRAY_NON_NULL(input, false);
     903    if (masks) {
     904        PS_ASSERT_ARRAY_NON_NULL(masks, false);
     905        PS_ASSERT_ARRAYS_SIZE_EQUAL(masks, input, false);
     906    }
    897907
    898908    if (input->n == 0) {
     
    903913    if (input->n == 1) {
    904914        // The problem reduces to one already solved
    905         return psFitsWriteImage(fits, header, input->data[0], 1, extname);
     915        return psFitsWriteImageWithMask(fits, header, input->data[0],
     916                                        masks ? masks->data[0] : NULL, maskVal, 1, extname);
    906917    }
    907918
     
    930941        psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS3", PS_META_REPLACE, "Number of image planes",
    931942                         input->n);
    932     if (! update) {
     943    if (!update) {
    933944        psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s."),
    934945                "NAXIS, NAXIS1, NAXIS2, NAXIS3");
     
    940951    // The first is an psFitsImageWrite to create the extension.
    941952    // The next are psFitsImageUpdate to write into the extension.
    942     if (! psFitsWriteImage(fits, headerCopy, input->data[0], input->n, extname)) {
     953    if (!psFitsWriteImageWithMask(fits, headerCopy, input->data[0],
     954                                  masks ? masks->data[0] : NULL, maskVal, input->n, extname)) {
    943955        psError(PS_ERR_UNKNOWN, false, _("Could not write image plane %d."), 0);
    944956        psFree(headerCopy);
     
    948960
    949961    for (int i = 1; i < input->n; i++) {
    950         if (! psFitsUpdateImage(fits, input->data[i], 0, 0, i)) {
     962        if (!psFitsUpdateImageWithMask(fits, input->data[i],
     963                                       masks ? masks->data[i] : NULL, maskVal, 0, 0, i)) {
    951964            psError(PS_ERR_UNKNOWN, false, _("Could not write image plane %d."), i);
    952965            return false;
     
    958971
    959972bool psFitsUpdateImageCube(psFits *fits, const psArray *input, int x0, int y0)
     973{
     974    return psFitsUpdateImageCubeWithMask(fits, input, NULL, 0, x0, y0);
     975}
     976
     977bool psFitsUpdateImageCubeWithMask(psFits *fits, const psArray *input,
     978                                   const psArray *masks, psMaskType maskVal, int x0, int y0)
    960979{
    961980    PS_ASSERT_FITS_NON_NULL(fits, false);
     
    969988
    970989    for (int i = 0; i < input->n; i++) {
    971         if (! psFitsUpdateImage(fits, input->data[i], x0, y0, i)) {
     990        if (!psFitsUpdateImageWithMask(fits, input->data[i],
     991                                       masks ? masks->data[i] : NULL, maskVal, x0, y0, i)) {
    972992            psError(PS_ERR_UNKNOWN, false, _("Could not update image plane %d."), i);
    973993            return false;
Note: See TracChangeset for help on using the changeset viewer.