On Dec 10, 2012, at 12:04 PM, Hyer, Dr. Edward wrote:

> Hello PDL geniuses,
> 
> So, I read in an ASCII file with rcols(), and then place its data into a 
> piddle like so:
> my 
> @data=rcols($fh,{INCLUDE=>$include,TYPES=>$types,PERLCOLS=>[0,16,17]},1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,19);
> # set up hash to output;
>    my %rph;         # Reformat Piddle Hash (Eggplant Susan Germane!)
> # Load strings into hash;
>    $rph{"DTG"}=$data[17];
>    $rph{"DATASOURCE"}=$data[18];
>    $rph{"AUX_A"}=$data[19];
>    $rph{"DOY"}=$data[0];
>    $rph{"LON"}=$data[1];
>    $rph{"LAT"}=$data[2];
> 
> 
> But sometimes there are bad data, which I can detect by tests on LAT and LON:
> my $lonvalues = $rph->{"LON"};
> my($goodlon)=where($lonvalues,($lonvalues >= -180)*($lonvalues <= 180));
> 
> But what I don't know is how to make a piddle using only the good values in 
> $goodlon. Can someone illustrate how to do this?
> 
> Thanks,
> 
> --Edward H.

Hi Edward,

I am confused about what you are unclear about.  All the values in $goodlon 
should be good, yes?  So do you need to filter other data based on good 
longitude values? If so, you can add multiple source piddles to the 'where' 
call:

my ($good_dtg, $good_aux_a, $good_lon) = where($dtg, $aux_a, $lonvalues, 
$lonvalues->abs<=180);

Or do you not want to write out another step for all of your data elements?  
Then maybe

$idx = which($lonvalues->abs<=180);
@good_data = map{   $_->($idx)   }@data;

Be aware that the piddles in @good_data still point back to their corresponding 
elements in @data, so add a '->sever' call inside the map{} if you don't want 
that.

cheers,
Derek
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to