Hi, Ed,
Great to see you’re getting into the guts of it!
I’m not a big user of HDF, but I *am* a big user of PDL, so maybe I can help
out.
The “null” PDL that you’re seeing in your error code is the output of the
“append”
method call. All of the autogenerated (primitive) operators that return
piddles do
so by creating a placeholder piddle that has no dimensional info yet. Such
values are called “null” because they’re wildcards from the standpoint of
threading.
What’s happening here is that append() works on the 0th dimension (all
operators with
active dimensions put them at the start of the dimension list).
So you’re starting with an 8x10264 variable and trying to append an 8x7638
variable
to it. The append method wants to create a 16 x <something> value out of those
two,
and can’t because 10264 and 7638 don’t thread.
There are two ways around that:
(1) use the “glue” method instead, as in
$big_piddle_hash{$_}->glue( 1, ${$little_piddle_hash}{$_} )
where the “1” in the glue dimlist specifies that you want to do the gluing along
dimension 1 instead of (as with append) dimension 0; or
(2) use stupid index tricks, as in
$big_piddle_hash{$_}->mv(1,0)->append(${$little_piddle_hash}{$_}->mv(1,0))->mv(0,1)
which switches the dimensions around so that append gets what it wants where it
wants.
Good luck!
Cheers,
Craig
> On Apr 4, 2016, at 2:27 PM, Hyer, Dr. Edward <[email protected]>
> wrote:
>
> Hi PDL Wizards,
>
> I am creating a routine that reads a sequence of HDF files, extracts their
> content, combines with some other information, and produces a data structure
> with the multi-file output. The final data structure is a hash with values
> that are either Perl arrays or piddles, depending on the data type. The code
> does this to combine the data from a single HDF file $little_piddle_hash
> into the multi-file output $big_piddle_hash :
>
> foreach(keys %big_piddle_hash){
> if(ref($big_piddle_hash{$_}) eq 'PDL'){
>
> $big_piddle_hash{$_}=$big_piddle_hash{$_}->append(${$little_piddle_hash}{$_}
> );
> } else {
>
> $big_piddle_hash{$_}=[$big_piddle_hash{$_},${$little_piddle_hash}{$_}];}
>
> The error from PDL looks like this:
>
> Uncaught exception from user code:
> PDL: PDL::Primitive::append(a,b,c): Parameter 'b':
> Mismatched implicit thread dimension 0: size 10264 vs. 7638
> There are 3 PDLs in the expression; 1 thread dim.
> PDL IN EXPR. ACTIVE DIMS | THREAD DIMS
> # 0 (normal): 8 | 10264
> # 1 (normal): 8 | 7638
> # 2 (null)
>
> My questions are these:
>
> Q1. It appears that '$fielddata = $hdfobj->SDget($field);' returns a 'null
> piddle' if the HDF file does not contain $field. Q1A: Why does it not just
> return undefined? Q1B: What is the easiest way to check for this condition?
>
> Q2: What other checks can I put in to avoid this error?
>
> Thanks in advance,
>
> --Edward H.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general
------------------------------------------------------------------------------
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general