Hi Christopher!
I'm glad to hear you're working with PDL.
There's no built-in direct access member for using the SDgetdimscale()
function like there is for the SDgetcal() functions. I inherited the
PDL::IO::HDF code from elsewhere, and I add new features to it on an
"extreme" basis (meaning if no one asks for the feature, it's not going
in).
However, a low-level PerlXS sub is generated for that function, so you
should be able to get to it. The trick will be preparing the data array
that will hold the output values.
I'll build this function in for the next release, but since it's part of
PDL itself now, you'll have to wait for the next stable to be ready to
go to use that.
In the mean time, I _think_ the below should work. You'll only need to
know the dataset name and dimension name as input.
Let me know if you have any trouble with it. If you do, then I'll
probably want to take a look at the HDF file you're using and do some
further testing here.
-Judd
my $want_file = "some_hdf_file.hdf";
my $want_dataset = "some_dataset_name";
my $want_dim = "some_dim_name";
# Make a PDL::IO::HDF::SD object:
#
my $hdf = PDL::IO::HDF::SD->new( $want_file );
# Get the dim id, based on the stored dimension information that's already in
# the $hdf object's internals:
#
my $dim_id = $hdf->{DATASET}->{$want_dataset}->{DIMS}->{$want_dim}->{DIMID};
# We will still need to call the internal _SDdiminfo() to get the number type
# for the dim scale (it's not already cached, like the dim id). Might as
# well get the dim size here also.
# NOTE: these aren't optional vars. We're allocating memory for the C call here!
#
my $scale_type = 0;
my $dimname = " "x(PDL::IO::HDF->MAX_NC_NAME+1);
my $dimsize = 0;
my $num_type = 0;
my $n_attrs = 0;
my $res = PDL::IO::HDF::SD::_SDdiminfo( $dim_id, $dimname, $dimsize, $num_type,
$n_attrs );
die "_SDdiminfo() failed!\n"
if( $res == PDL::IO::HDF->FAIL );
# Allocate a PDL variable that can be used as a C array to hold the output
# dim scale data:
#
my $scale = zeroes( $PDL::IO::HDF::SDinvtypeTMAP2->{$num_type}, $dimsize );
# Call the internal SDgetdimscale() function:
#
$res = PDL::IO::HDF::SD::_SDgetdimscale( $dim_id, $scale );
die "_SDgetdimscale() failed!\n"
if( $res == PDL::IO::HDF->FAIL );
# The dimension scale data is now stored in the $scale piddle!
On Fri, 2008-03-07 at 15:39 -0500, Christopher Lynnes wrote:
> Judd,
> Does PDL::IO::HDF::SD have the getdimscale call? (The man page is
> silent on this topic...) If so, what is the syntax? Can I give it a
> dim name or do I need to track down the dimid?
>
> Thanks!
--
____________________________
Judd Taylor
Software Engineer
Orbital Systems, Ltd.
3807 Carbon Rd.
Irving, TX 75038-3415
[EMAIL PROTECTED]
(972) 915-3669 x127
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl