IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28262


Ignore:
Timestamp:
Jun 8, 2010, 3:50:09 PM (16 years ago)
Author:
watersc1
Message:

Update to add flux error, which I forgot about previously.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/detectability_respond.pl

    r27859 r28262  
    226226my @psphot_Qfact= ();
    227227my @psphot_flux = ();
     228my @psphot_error = ();
    228229
    229230foreach my $k (keys %image_list_hash) {
     
    231232        my $cmf = "$image_list_hash{$k}{OUTROOT}.$image_list_hash{$k}{CLASS_ID}.cmf";
    232233       
    233         my ($tmp_Npix,$tmp_Qfact,$tmp_flux) = read_cmf_file($cmf,$image_list_hash{$k}{EXTENSION_BASE});
     234        my ($tmp_Npix,$tmp_Qfact,$tmp_flux,$tmp_flux_error) = read_cmf_file($cmf,$image_list_hash{$k}{EXTENSION_BASE});
    234235       
    235236        push @rownums,        @{ $image_list_hash{$k}{ROWNUM} };
     
    238239        push @psphot_Qfact,   @{ $tmp_Qfact };
    239240        push @psphot_flux,    @{ $tmp_flux };
     241        push @psphot_error,   @{ $tmp_flux_error };
    240242    }
    241243    else {
     
    245247        push @psphot_Qfact,   (map { 0.0 }  @{ $image_list_hash{$k}{ROWNUM} });
    246248        push @psphot_flux,    (map { 0.0 }  @{ $image_list_hash{$k}{ROWNUM} });
     249        push @psphot_error,    (map { 0.0 }  @{ $image_list_hash{$k}{ROWNUM} });
    247250    }   
    248251}
     
    252255                    $query{HEADER}{MJD_OBS}[0],$query{HEADER}{filter}[0],
    253256                    $query{HEADER}{obscode}[0],
    254                     \@rownums, \@out_errors, \@psphot_Npix, \@psphot_Qfact, \@psphot_flux);
     257                    \@rownums, \@out_errors, \@psphot_Npix, \@psphot_Qfact, \@psphot_flux, \@psphot_error);
    255258# print "Wrote response file $output\n";
    256259#
     
    406409    my @tmp_Qfact = ();
    407410    my @tmp_flux = ();
     411    my @tmp_flux_err = ();
    408412
    409413    my ($detect_F_col,$detect_N_col,$detect_flux_col,$detect_mag_col) = (-1, -1, -1, -1);
     
    428432            { name => 'PSF_NPIX', type => '1J', writetype => TLONG },
    429433            { name => 'PSF_INST_MAG', type => '1E', writetype => TDOUBLE },
     434            { name => 'PSF_INST_MAG_SIG', type => '1E', writetype => TDOUBLE },
    430435            ];
    431436    }
     
    435440            { name => 'PSF_NPIX', type => '1J', writetype => TLONG },
    436441            { name => 'PSF_INST_FLUX', type => '1E', writetype => TDOUBLE },
     442            { name => 'PSF_INST_FLUX_SIG', type => '1E', writetype => TDOUBLE },
    437443            ];
    438444    }
     
    450456    $inFits->get_num_rows($numRows, $status) and check_fitsio($status);
    451457
     458    my $correct_error = 0;
    452459    foreach my $col (@$column_defs) {
    453460        my ($col_num,$col_type,$col_data);
     
    469476            @tmp_flux = map { $_ = 10**(-0.4 * $_) } @{ $col_data };
    470477        }
     478        elsif ($col->{name} eq 'PSF_INST_MAG_SIG') {
     479            @tmp_flux_err = map { $_ = $_ / (2.5 * log10(exp(1))) } @{ $col_data };
     480            $correct_error = 1;
     481        }
    471482        elsif ($col->{name} eq 'PSF_INST_FLUX') {
    472483            @tmp_flux = @{ $col_data };
    473484        }
     485        elsif ($col->{name} eq 'PSF_INST_FLUX_SIG') {
     486            @tmp_flux_err = @{ $col_data };
     487        }
     488    }
     489    if ($correct_error) {
     490        for (my $c = 0; $c <= $#tmp_flux_err; $c++) {
     491            $tmp_flux_err[$c] = $tmp_flux_err[$c] * $tmp_flux[$c];
     492        }
    474493    }
    475494    $inFits->close_file( $status ) and check_fitsio($status);   
    476     return(\@tmp_Npix, \@tmp_Qfact, \@tmp_flux);
     495    return(\@tmp_Npix, \@tmp_Qfact, \@tmp_flux, \@tmp_flux_err);
    477496}
    478497
     
    490509    my $psphot_Qfact_ref = shift;
    491510    my $psphot_flux_ref = shift;
     511    my $psphot_error_ref = shift;
    492512    my $status = 0;
    493513
     
    504524        # flux of the target source
    505525        { name => 'TARGET_FLUX', type => 'D', writetype => TDOUBLE },
     526        # error in the flux of the target source
     527        { name => 'TARGET_FLUX_SIG', type => 'D', writetype => TDOUBLE },
    506528        ];
    507529   
     
    543565        push @{$colData{'DETECT_F'}},    ${ $psphot_Qfact_ref }[$i];
    544566        push @{$colData{'TARGET_FLUX'}}, ${ $psphot_flux_ref }[$i];
     567        push @{$colData{'TARGET_FLUX_SIG'}}, ${ $psphot_error_ref }[$i];
    545568        unless (defined(${ $colData{'TARGET_FLUX'}}[-1])) {
    546569            $colData{'TARGET_FLUX'}[-1] = 0.0;
     570        }
     571        unless (defined(${ $colData{'TARGET_FLUX_SIG'}}[-1])) {
     572            $colData{'TARGET_FLUX_SIG'}[-1] = 0.0;
    547573        }
    548574    }
Note: See TracChangeset for help on using the changeset viewer.