Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t/proj_transform2.t test failures #498

Closed
shawnlaffan opened this issue Oct 2, 2024 · 38 comments
Closed

t/proj_transform2.t test failures #498

shawnlaffan opened this issue Oct 2, 2024 · 38 comments

Comments

@shawnlaffan
Copy link
Contributor

t/proj_transform2.t is failing tests on my Ubuntu system (Ubuntu 20.04.6 LTS via WSL2) for PDL 2.093 and HEAD.

Alien::proj is a share install, so it is not using the system version of Proj. Proj is at version 9.4.1.

First failing commit is c3bf22f

FWIW, the system version of Proj is 6.3.1. I have not tested with it, but there have been many changes since that was released.

perl -v | head -2 | tail -1
This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux
make[2]: Entering directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform'
"/home/shawn/perl5/perlbrew/perls/perl-5.40.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Transform.bs ../../blib/arch/auto/PDL/Transform/Transform.bs 644
make[3]: Entering directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform/Cartography'
Manifying 1 pod document
make[3]: Leaving directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform/Cartography'
make[3]: Entering directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform/Proj4'
"/home/shawn/perl5/perlbrew/perls/perl-5.40.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Proj4.bs ../../../blib/arch/auto/PDL/Transform/Proj4/Proj4.bs 644
Manifying 1 pod document
make[3]: Leaving directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform/Proj4'
make[3]: Entering directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform/Cartography'
No tests defined for PDL::Transform::Cartography extension.
make[3]: Leaving directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform/Cartography'
make[3]: Entering directory '/mnt/c/git/pdl_repos/pdl/Libtmp/Transform/Proj4'
"/home/shawn/perl5/perlbrew/perls/perl-5.40.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Proj4.bs ../../../blib/arch/auto/PDL/Transform/Proj4/Proj4.bs 644
PERL_DL_NONLAZY=1 "/home/shawn/perl5/perlbrew/perls/perl-5.40.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, '../../../blib/lib', '../../../blib/arch')" t/*.t
t/gis_proj.t ......... # ENV LD_LIBRARY_PATH = undef
# ENV DYLD_LIBRARY_PATH = undef
# ENV LDFLAGS = undef
# ENV CFLAGS = undef
# ENV CXXFLAGS = undef
# ENV LD_RUN_PATH = undef
# ENV LC_RUN_PATH = undef
# Alien::proj version 1.27
t/gis_proj.t ......... 1/? # PROJ version: 9 4 1
t/gis_proj.t ......... ok
t/proj_transform.t ... skipped: The jpegtopnm utility (needed for proj_transform.t tests) not found.
t/proj_transform2.t .. 1/?
#   Failed test 'check ref_ortho for slices[0]'
#   at t/proj_transform2.t line 73.
# got:
#
# [
#  [116 117 117 117]
#  [128 129 125 125]
#  [136 137 133 133]
#  [144 141 141 141]
# ]
#
# expected:
#
# [
#  [116 117 117 117]
#  [128 129 125 125]
#  [136 137 133 133]
#  [144 145 141 141]
# ]

#   Failed test 'check ref_ortho2 for slices[0]'
#   at t/proj_transform2.t line 87.
# got:
#
# [
#  [116 117 117 117]
#  [128 129 125 125]
#  [136 137 133 133]
#  [144 141 141 141]
# ]
#
# expected:
#
# [
#  [116 117 117 117]
#  [128 129 125 125]
#  [136 137 133 133]
#  [144 145 141 141]
# ]
# Looks like you failed 2 tests of 20.
t/proj_transform2.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/20 subtests
@mohawk2
Copy link
Member

mohawk2 commented Oct 3, 2024

That 145 vs 141 is likely due to some rounding/quantisation difference between Windows and Linux and/or compiler versions. Sorry about this, and thanks for the report. The tests that have been used up till now, using map, I now believe to be non-ideal, and a more idiomatic way to test that module is just to directly transform a few coordinates using apply, which is what map does anyway.

@mohawk2
Copy link
Member

mohawk2 commented Oct 3, 2024

@shawnlaffan Could you try the latest HEAD version? Until now, the Proj binding has been allowing the default of pthreading for larger input data, but calling into PROJ in a non-thread-safe way.

I'm still going to switch to doing the coordinate transformation directly, which will be a smaller, quicker, and more accurate test, but I'd like to see if the pthread thing is the cause of this issue.

@shawnlaffan
Copy link
Contributor Author

Just built and tested with HEAD and unfortunately the failures remain.

Windows will not be the issue as this is an Ubuntu instance (it just happens to be running via WSL2). gcc details are below.

> gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-9QDOt0/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)

@mohawk2
Copy link
Member

mohawk2 commented Oct 4, 2024

Could you try with the latest HEAD as linked above? And if it works, please close :-)

@dhdeangelis
Copy link

dhdeangelis commented Oct 4, 2024

I found that the test errors disappear if one adds use PDL::IO::FITS; to proj_transform2.t

Tested in openSUSE Tumbleweed, Perl 5.40.0

@mohawk2
Copy link
Member

mohawk2 commented Oct 4, 2024

Good heavens! That does not sound like it should work. Are you sure it's not just intermittent? Also, @dhdeangelis could you also try the latest master version and see if the errors go away?

@dhdeangelis
Copy link

dhdeangelis commented Oct 5, 2024

I am sure it is not intermittent. But I do not completely understand the reason. Short summary:

PDL-2.092: built and test OK

PDL-2.093: built OK, failed test for proj_transform2:

t/gis_proj.t ......... 1/? # PROJ version: 9 5 0
t/gis_proj.t ......... ok   
t/proj_transform.t ... ok     
t/proj_transform2.t .. 1/? 
#   Failed test 'check ref_ortho for slices[0]: result was BAD value'
#   at t/proj_transform2.t line 73.

#   Failed test 'check ref_ortho for slices[1]: result was BAD value'
#   at t/proj_transform2.t line 73.

#   Failed test 'check ref_ortho for slices[2]: result was BAD value'
#   at t/proj_transform2.t line 73.

#   Failed test 'check ref_ortho for slices[3]: result was BAD value'
#   at t/proj_transform2.t line 73.

#   Failed test 'check ref_ortho for slices[4]: result was BAD value'
#   at t/proj_transform2.t line 73.
# Looks like you failed 5 tests of 20.
t/proj_transform2.t .. Dubious, test returned 5 (wstat 1280, 0x500)
Failed 5/20 subtests 

Upon investigation I saw baffling things like if printing $map to stdout before $ortho the test passes:

   ###############
   # TESTS 6-10: #
   ###############
   # Get Ortho reference data:
   my @ref_ortho_slices = get_ref_ortho_slices();
   # Check Ortho map against reference:
   my $ortho_opts = "+proj=ortho +ellps=WGS84 +lon_0=-90 +lat_0=40";

  # printing map before ortho makes the test pass ... why?
   print $map; 
  
  my $ortho = $map->map( t_proj( proj_params => $ortho_opts ), $map_size );
    foreach my $i ( 0 .. $#slices )
    {
        my $str = $slices[$i];
        my $slice = $ortho->slice($str);
        pdl_cmp(scalar $slice, $ref_ortho_slices[$i], "check ref_ortho for slices[$i]");
    }

Apart from simplification, perhaps the main change from 2.092 to 2.093 was the use of raster2fits. I suspected that something was required and was not properly being called. I tested with the list of modules called by "use PDL;" and by elimination it turned out to be possible to pass tests by calling use PDL::IO::FITS;
I assumed it was something in my system.

PDL-2.093: with a modified proj_transform2, adding use PDL::IO::FITS;

use strict;
use warnings;
use PDL::LiteF;
use PDL::IO::FITS;
use PDL::Transform::Proj4;
use PDL::Transform::Cartography;
use Test::More;

built OK, test OK:

# Alien::proj version 1.27
t/gis_proj.t ......... 1/? # PROJ version: 9 5 0
t/gis_proj.t ......... ok   
t/proj_transform.t ... ok     
t/proj_transform2.t .. ok  

Now, master does not have a proj_transform2.t test anymore. It builds and tests correctly:

# Alien::proj version 1.27
t/gis_proj.t ........ 1/? # PROJ version: 9 5 0
t/gis_proj.t ........ ok   
t/proj_transform.t .. ok   
All tests successful.

All the steps above are reproducible in my system.

Perl (built by me, not the OS's):

> /usr/local/bin/perl --version
This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux

System info:

> inxi -S
System:
  Host: localhost.localdomain Kernel: 6.11.0-1-default arch: x86_64 bits: 64
  Desktop: Xfce v: 4.18.1 Distro: openSUSE Tumbleweed 20241003

Hope this adds light. Perhaps it is not necessary anymore, although it would be interesting to know more about the root cause.

@mohawk2
Copy link
Member

mohawk2 commented Oct 5, 2024

Yes, I'd like to know why also. I'm currently tracking two further bugs in IO::FITS (the RICE compression doesn't seem to round-trip in at least one circumstance), and the COMMENT field is currently becoming a stringified hash, which is bizarre. Let's try to catch this one too.

A thing I suspect is that the test used PDL::LiteF, which doesn't do the full loading of things including use PDL::IO::FITS that use PDL does. The FITS module loads Astro::FITS::Header, and since PDL::Transform's map method is FITS-aware, that's probably making a difference. In fact, that would probably explain the highly intermittent failures that test has had for years; IO::FITS behaves a bit differently if A:F:H isn't installed. This is likely to come down to a fixable failing in the A:F:H emulation code, which had another bug I fixed recently.

Could you do a $map->dump; print explain $map->gethdr before and after the print $map, both with and without the use PDL::IO::FITS?

@dhdeangelis
Copy link

@mohawk2 here comes the results of the tests you asked for. I separate in two comments for clarity. Spoiler alert: this is confusing.

  1. "unmodified" proj_transform2.t as it comes in PDL-2.093
use strict;
use warnings;
use PDL::LiteF;
use PDL::Transform::Proj4;
use PDL::Transform::Cartography;
use Test::More;

Suggested test:

###############
# TESTS 6-10: #
###############
# Get Ortho reference data:
my @ref_ortho_slices = get_ref_ortho_slices();

# Check Ortho map against reference:
my $ortho_opts = "+proj=ortho +ellps=WGS84 +lon_0=-90 +lat_0=40";

$map->dump; print explain $map->gethdr;

print $map;

$map->dump; print explain $map->gethdr;

my $ortho = $map->map( t_proj( proj_params => $ortho_opts ), $map_size );
foreach my $i ( 0 .. $#slices )
{
   my $str = $slices[$i];
   my $slice = $ortho->slice($str);
   pdl_cmp($slice, $ref_ortho_slices[$i], "check ref_ortho for slices[$i]");
}

Output: failure

> /usr/local/bin/perl proj_transform2.t 
ok 1 - check ref_eqc for slices[0]
ok 2 - check ref_eqc for slices[1]
ok 3 - check ref_eqc for slices[2]
ok 4 - check ref_eqc for slices[3]
ok 5 - check ref_eqc for slices[4]
DUMPING 0x377da210     datatype: 1
   State: (1537) PDL_ALLOCATED|PDL_HDRCPY|PDL_BADVAL
   transvtable: (nil), trans: (nil), sv: 0x377ccd80
   datasv: 0x377cd458, Svlen: 8192, refcnt: 1
   data: 0x3979bd90, nbytes: 8192, nvals: 8192
   hdrsv: 0x377cd3b0, reftype REF
   Dims: 0x377da310 (128 64)
   BroadcastIds: 0x377da370 (2)
   Badvalue (orig): 255
   First values: (0 0 0 0 0 0 0 0 0 0)
   CHILDREN:
{
  'CDELT1' => '2.8125',
  'CDELT2' => '2.8125',
  'CRPIX1' => '64.5',
  'CRPIX2' => '32.5',
  'CRVAL1' => 0,
  'CRVAL2' => 0,
  'CTYPE1' => 'Longitude',
  'CTYPE2' => 'Latitude',
  'CUNIT1' => 'degrees',
  'CUNIT2' => 'degrees',
  'HISTORY' => 'PDL conversion from raster image',
  'NAXIS' => 2,
  'NAXIS1' => 128,
  'NAXIS2' => 64,
  'SIMPLE' => 'T'
}

[
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3]
 [  3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7]
 [  7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11]
 [ 11  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15]
 [ 15  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19]
 [ 19  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23]
 [ 23  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27]
 [ 27  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31]
 [ 31  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35]
 [ 35  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39]
 [ 39  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43]
 [ 43  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47]
 [ 47  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51]
 [ 51  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55]
 [ 55  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59]
 [ 59  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63]
 [ 63  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67]
 [ 67  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71]
 [ 71  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75]
 [ 75  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79]
 [ 79  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83]
 [ 83  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87]
 [ 87  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91]
 [ 91  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95]
 [ 95  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99]
 [ 99 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103]
 [103 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107]
 [107 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111]
 [111 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115]
 [115 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119]
 [119 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123]
 [123 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127]
 [127 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131]
 [131 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135]
 [135 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139]
 [139 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143]
 [143 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147]
 [147 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151]
 [151 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155]
 [155 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159]
 [159 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163]
 [163 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167]
 [167 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171]
 [171 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175]
 [175 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179]
 [179 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183]
 [183 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187]
 [187 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191]
 [191 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195]
 [195 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199]
 [199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203]
 [203 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207]
 [207 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211]
 [211 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215]
 [215 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219]
 [219 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223]
 [223 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227]
 [227 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231]
 [231 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235]
 [235 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239]
 [239 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243]
 [243 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247]
 [247 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251]
 [251 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD]
]
DUMPING 0x377da210     datatype: 1
   State: (1537) PDL_ALLOCATED|PDL_HDRCPY|PDL_BADVAL
   transvtable: (nil), trans: (nil), sv: 0x377ccd80
   datasv: 0x377cd458, Svlen: 8192, refcnt: 1
   data: 0x3979bd90, nbytes: 8192, nvals: 8192
   hdrsv: 0x377cd3b0, reftype REF
   Dims: 0x377da310 (128 64)
   BroadcastIds: 0x377da370 (2)
   Badvalue (orig): 255
   First values: (0 0 0 0 0 0 0 0 0 0)
   CHILDREN:
{
  'CDELT1' => '2.8125',
  'CDELT2' => '2.8125',
  'CRPIX1' => '64.5',
  'CRPIX2' => '32.5',
  'CRVAL1' => 0,
  'CRVAL2' => 0,
  'CTYPE1' => 'Longitude',
  'CTYPE2' => 'Latitude',
  'CUNIT1' => 'degrees',
  'CUNIT2' => 'degrees',
  'HISTORY' => 'PDL conversion from raster image',
  'NAXIS' => 2,
  'NAXIS1' => 128,
  'NAXIS2' => 64,
  'SIMPLE' => 'T'
}
not ok 6 - check ref_ortho for slices[0]: result was BAD value
#   Failed test 'check ref_ortho for slices[0]: result was BAD value'
#   at proj_transform2.t line 80.
not ok 7 - check ref_ortho for slices[1]: result was BAD value
#   Failed test 'check ref_ortho for slices[1]: result was BAD value'
#   at proj_transform2.t line 80.
not ok 8 - check ref_ortho for slices[2]: result was BAD value
#   Failed test 'check ref_ortho for slices[2]: result was BAD value'
#   at proj_transform2.t line 80.
not ok 9 - check ref_ortho for slices[3]: result was BAD value
#   Failed test 'check ref_ortho for slices[3]: result was BAD value'
#   at proj_transform2.t line 80.
not ok 10 - check ref_ortho for slices[4]: result was BAD value
#   Failed test 'check ref_ortho for slices[4]: result was BAD value'
#   at proj_transform2.t line 80.
ok 11 - check ref_ortho2 for slices[0]
ok 12 - check ref_ortho2 for slices[1]
ok 13 - check ref_ortho2 for slices[2]
ok 14 - check ref_ortho2 for slices[3]
ok 15 - check ref_ortho2 for slices[4]
ok 16 - check ref_robin for slices[0]
ok 17 - check ref_robin for slices[1]
ok 18 - check ref_robin for slices[2]
ok 19 - check ref_robin for slices[3]
ok 20 - check ref_robin for slices[4]
1..20
# Looks like you failed 5 tests of 20.

But, just if we do only dumping or printing the test passes:

   ###############
   # TESTS 6-10: #
   ###############
   # Get Ortho reference data:
   my @ref_ortho_slices = get_ref_ortho_slices();

   # Check Ortho map against reference:
   my $ortho_opts = "+proj=ortho +ellps=WGS84 +lon_0=-90 +lat_0=40";
   
#    $map->dump; print explain $map->gethdr;
   
#    print $map;
   
   $map->dump; print explain $map->gethdr;
   
   my $ortho = $map->map( t_proj( proj_params => $ortho_opts ), $map_size );
   foreach my $i ( 0 .. $#slices )
   {
      my $str = $slices[$i];
      my $slice = $ortho->slice($str);
      pdl_cmp($slice, $ref_ortho_slices[$i], "check ref_ortho for slices[$i]");
   }

Resulting in:

> /usr/local/bin/perl proj_transform2.t 
ok 1 - check ref_eqc for slices[0]
ok 2 - check ref_eqc for slices[1]
ok 3 - check ref_eqc for slices[2]
ok 4 - check ref_eqc for slices[3]
ok 5 - check ref_eqc for slices[4]
DUMPING 0x37f4a210     datatype: 1
   State: (1537) PDL_ALLOCATED|PDL_HDRCPY|PDL_BADVAL
   transvtable: (nil), trans: (nil), sv: 0x37f3cd80
   datasv: 0x37f3d458, Svlen: 8192, refcnt: 1
   data: 0x39f0b000, nbytes: 8192, nvals: 8192
   hdrsv: 0x37f3d3b0, reftype REF
   Dims: 0x37f4a310 (128 64)
   BroadcastIds: 0x37f4a370 (2)
   Badvalue (orig): 255
   First values: (0 0 0 0 0 0 0 0 0 0)
   CHILDREN:
{
  'CDELT1' => '2.8125',
  'CDELT2' => '2.8125',
  'CRPIX1' => '64.5',
  'CRPIX2' => '32.5',
  'CRVAL1' => 0,
  'CRVAL2' => 0,
  'CTYPE1' => 'Longitude',
  'CTYPE2' => 'Latitude',
  'CUNIT1' => 'degrees',
  'CUNIT2' => 'degrees',
  'HISTORY' => 'PDL conversion from raster image',
  'NAXIS' => 2,
  'NAXIS1' => 128,
  'NAXIS2' => 64,
  'SIMPLE' => 'T'
}
ok 6 - check ref_ortho for slices[0]
ok 7 - check ref_ortho for slices[1]
ok 8 - check ref_ortho for slices[2]
ok 9 - check ref_ortho for slices[3]
ok 10 - check ref_ortho for slices[4]
ok 11 - check ref_ortho2 for slices[0]
ok 12 - check ref_ortho2 for slices[1]
ok 13 - check ref_ortho2 for slices[2]
ok 14 - check ref_ortho2 for slices[3]
ok 15 - check ref_ortho2 for slices[4]
ok 16 - check ref_robin for slices[0]
ok 17 - check ref_robin for slices[1]
ok 18 - check ref_robin for slices[2]
ok 19 - check ref_robin for slices[3]
ok 20 - check ref_robin for slices[4]
1..20

@dhdeangelis
Copy link

dhdeangelis commented Oct 5, 2024

  1. "modified" proj_transform2.t :
use strict;
use warnings;
use PDL::LiteF;
use PDL::IO::FITS;
use PDL::Transform::Proj4;
use PDL::Transform::Cartography;
use Test::More;

Suggested test:

   ###############
   # TESTS 6-10: #
   ###############
   # Get Ortho reference data:
   my @ref_ortho_slices = get_ref_ortho_slices();

   # Check Ortho map against reference:
   my $ortho_opts = "+proj=ortho +ellps=WGS84 +lon_0=-90 +lat_0=40";
   
   $map->dump; print explain $map->gethdr;
   
   print $map;
   
   $map->dump; print explain $map->gethdr;
   
   my $ortho = $map->map( t_proj( proj_params => $ortho_opts ), $map_size );
   foreach my $i ( 0 .. $#slices )
   {
      my $str = $slices[$i];
      my $slice = $ortho->slice($str);
      pdl_cmp($slice, $ref_ortho_slices[$i], "check ref_ortho for slices[$i]");
   }

Result: failure (as in the previous case)

> /usr/local/bin/perl proj_transform2.t
ok 1 - check ref_eqc for slices[0]
ok 2 - check ref_eqc for slices[1]
ok 3 - check ref_eqc for slices[2]
ok 4 - check ref_eqc for slices[3]
ok 5 - check ref_eqc for slices[4]
DUMPING 0x34387260     datatype: 1
   State: (1537) PDL_ALLOCATED|PDL_HDRCPY|PDL_BADVAL
   transvtable: (nil), trans: (nil), sv: 0x34379ea0
   datasv: 0x3437a3e0, Svlen: 8192, refcnt: 1
   data: 0x365bb500, nbytes: 8192, nvals: 8192
   hdrsv: 0x35425678, reftype REF
   Dims: 0x34387360 (128 64)
   BroadcastIds: 0x343873c0 (2)
   Badvalue (orig): 255
   First values: (0 0 0 0 0 0 0 0 0 0)
   CHILDREN:
{
  'CDELT1' => '2.8125',
  'CDELT2' => '2.8125',
  'CRPIX1' => '64.5',
  'CRPIX2' => '32.5',
  'CRVAL1' => '0',
  'CRVAL2' => '0',
  'CTYPE1' => 'Longitude',
  'CTYPE2' => 'Latitude',
  'CUNIT1' => 'degrees',
  'CUNIT2' => 'degrees',
  'HISTORY' => 'PDL conversion from raster image
',
  'NAXIS' => '2',
  'NAXIS1' => '128',
  'NAXIS2' => '64',
  'SIMPLE' => 'T'
}

[
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3]
 [  3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7]
 [  7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11  11]
 [ 11  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  12  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  13  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  14  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15  15]
 [ 15  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  16  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  17  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  18  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19  19]
 [ 19  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  20  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  21  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  22  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23  23]
 [ 23  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  24  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  25  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  26  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27  27]
 [ 27  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  28  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  29  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  30  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31  31]
 [ 31  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  33  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  34  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35  35]
 [ 35  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  36  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  37  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  38  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39  39]
 [ 39  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  41  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  42  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43  43]
 [ 43  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  44  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  45  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  46  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47  47]
 [ 47  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  49  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  50  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51  51]
 [ 51  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  52  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  53  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  54  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55  55]
 [ 55  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  56  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  57  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  58  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59  59]
 [ 59  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  61  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  62  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63  63]
 [ 63  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  64  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  65  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  66  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67  67]
 [ 67  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  68  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  69  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  70  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71  71]
 [ 71  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  72  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  73  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  74  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75  75]
 [ 75  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  76  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  77  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  78  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79  79]
 [ 79  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  80  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  81  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  82  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83  83]
 [ 83  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  84  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  85  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  86  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87]
 [ 87  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  88  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  89  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91  91]
 [ 91  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  92  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  93  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  94  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95  95]
 [ 95  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  96  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  97  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99  99]
 [ 99 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103 103]
 [103 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 104 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 105 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107 107]
 [107 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 108 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111]
 [111 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 112 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115]
 [115 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 116 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119]
 [119 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123]
 [123 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 125 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127]
 [127 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131 131]
 [131 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 133 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135]
 [135 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 137 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139 139]
 [139 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143]
 [143 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 144 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147]
 [147 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 148 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 149 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151]
 [151 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155]
 [155 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 156 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 158 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159]
 [159 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 161 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163]
 [163 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167]
 [167 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171 171]
 [171 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 172 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175]
 [175 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 177 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179]
 [179 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183]
 [183 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 186 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187]
 [187 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191 191]
 [191 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 193 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195 195]
 [195 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 196 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 197 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 198 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199]
 [199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203 203]
 [203 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207]
 [207 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 208 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211 211]
 [211 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 214 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215]
 [215 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219 219]
 [219 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 220 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 222 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223 223]
 [223 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227 227]
 [227 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 229 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 230 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231]
 [231 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 233 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235 235]
 [235 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 237 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239]
 [239 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243]
 [243 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 245 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247]
 [247 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 249 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251]
 [251 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD]
]
DUMPING 0x34387260     datatype: 1
   State: (1537) PDL_ALLOCATED|PDL_HDRCPY|PDL_BADVAL
   transvtable: (nil), trans: (nil), sv: 0x34379ea0
   datasv: 0x3437a3e0, Svlen: 8192, refcnt: 1
   data: 0x365bb500, nbytes: 8192, nvals: 8192
   hdrsv: 0x35425678, reftype REF
   Dims: 0x34387360 (128 64)
   BroadcastIds: 0x343873c0 (2)
   Badvalue (orig): 255
   First values: (0 0 0 0 0 0 0 0 0 0)
   CHILDREN:
{
  'CDELT1' => '2.8125',
  'CDELT2' => '2.8125',
  'CRPIX1' => '64.5',
  'CRPIX2' => '32.5',
  'CRVAL1' => '0',
  'CRVAL2' => '0',
  'CTYPE1' => 'Longitude',
  'CTYPE2' => 'Latitude',
  'CUNIT1' => 'degrees',
  'CUNIT2' => 'degrees',
  'HISTORY' => 'PDL conversion from raster image
',
  'NAXIS' => '2',
  'NAXIS1' => '128',
  'NAXIS2' => '64',
  'SIMPLE' => 'T'
}
not ok 6 - check ref_ortho for slices[0]: result was BAD value
#   Failed test 'check ref_ortho for slices[0]: result was BAD value'
#   at proj_transform2.t line 81.
not ok 7 - check ref_ortho for slices[1]: result was BAD value
#   Failed test 'check ref_ortho for slices[1]: result was BAD value'
#   at proj_transform2.t line 81.
not ok 8 - check ref_ortho for slices[2]: result was BAD value
#   Failed test 'check ref_ortho for slices[2]: result was BAD value'
#   at proj_transform2.t line 81.
not ok 9 - check ref_ortho for slices[3]: result was BAD value
#   Failed test 'check ref_ortho for slices[3]: result was BAD value'
#   at proj_transform2.t line 81.
not ok 10 - check ref_ortho for slices[4]: result was BAD value
#   Failed test 'check ref_ortho for slices[4]: result was BAD value'
#   at proj_transform2.t line 81.
ok 11 - check ref_ortho2 for slices[0]
ok 12 - check ref_ortho2 for slices[1]
ok 13 - check ref_ortho2 for slices[2]
ok 14 - check ref_ortho2 for slices[3]
ok 15 - check ref_ortho2 for slices[4]
ok 16 - check ref_robin for slices[0]
ok 17 - check ref_robin for slices[1]
ok 18 - check ref_robin for slices[2]
ok 19 - check ref_robin for slices[3]
ok 20 - check ref_robin for slices[4]
1..20
# Looks like you failed 5 tests of 20.

But, as in the previous case, dumping or printing causes the test to pass

   ###############
   # TESTS 6-10: #
   ###############
   # Get Ortho reference data:
   my @ref_ortho_slices = get_ref_ortho_slices();

   # Check Ortho map against reference:
   my $ortho_opts = "+proj=ortho +ellps=WGS84 +lon_0=-90 +lat_0=40";
   
#    $map->dump; print explain $map->gethdr;
   
#    print $map;
   
   $map->dump; print explain $map->gethdr;
   
   my $ortho = $map->map( t_proj( proj_params => $ortho_opts ), $map_size );
   foreach my $i ( 0 .. $#slices )
   {
      my $str = $slices[$i];
      my $slice = $ortho->slice($str);
      pdl_cmp($slice, $ref_ortho_slices[$i], "check ref_ortho for slices[$i]");
   }
> /usr/local/bin/perl proj_transform2.t
ok 1 - check ref_eqc for slices[0]
ok 2 - check ref_eqc for slices[1]
ok 3 - check ref_eqc for slices[2]
ok 4 - check ref_eqc for slices[3]
ok 5 - check ref_eqc for slices[4]
DUMPING 0x12773260     datatype: 1
   State: (1537) PDL_ALLOCATED|PDL_HDRCPY|PDL_BADVAL
   transvtable: (nil), trans: (nil), sv: 0x12765ea0
   datasv: 0x127663e0, Svlen: 8192, refcnt: 1
   data: 0x149a7bb0, nbytes: 8192, nvals: 8192
   hdrsv: 0x13811928, reftype REF
   Dims: 0x12773360 (128 64)
   BroadcastIds: 0x127733c0 (2)
   Badvalue (orig): 255
   First values: (0 0 0 0 0 0 0 0 0 0)
   CHILDREN:
{
  'CDELT1' => '2.8125',
  'CDELT2' => '2.8125',
  'CRPIX1' => '64.5',
  'CRPIX2' => '32.5',
  'CRVAL1' => '0',
  'CRVAL2' => '0',
  'CTYPE1' => 'Longitude',
  'CTYPE2' => 'Latitude',
  'CUNIT1' => 'degrees',
  'CUNIT2' => 'degrees',
  'HISTORY' => 'PDL conversion from raster image
',
  'NAXIS' => '2',
  'NAXIS1' => '128',
  'NAXIS2' => '64',
  'SIMPLE' => 'T'
}
ok 6 - check ref_ortho for slices[0]
ok 7 - check ref_ortho for slices[1]
ok 8 - check ref_ortho for slices[2]
ok 9 - check ref_ortho for slices[3]
ok 10 - check ref_ortho for slices[4]
ok 11 - check ref_ortho2 for slices[0]
ok 12 - check ref_ortho2 for slices[1]
ok 13 - check ref_ortho2 for slices[2]
ok 14 - check ref_ortho2 for slices[3]
ok 15 - check ref_ortho2 for slices[4]
ok 16 - check ref_robin for slices[0]
ok 17 - check ref_robin for slices[1]
ok 18 - check ref_robin for slices[2]
ok 19 - check ref_robin for slices[3]
ok 20 - check ref_robin for slices[4]
1..20

As it seems, PDL::IO::FITS did not change things. As you suspected.
EDIT: without calling print or dump, the modified test with use PDL::IO::FITS passes, as reported before

I hope you find some clarity here.

@mohawk2
Copy link
Member

mohawk2 commented Oct 6, 2024

Thank you for your efforts so far on this! I don't have clarity yet, sadly. One observation is that inherently by the nature of a byte's range, and that it's a sequence, and that it's got badvalue == 255, the print shows some bad values which are a bit spurious.

It would be very valuable to see when pdl_cmp is reporting a failure, what its exact failure is? This is actually valuable as I'm just looking at incorporating Test::PDL into main-PDL, and the kind of thing it would be useful for it to report is clarified by this. Here, I'd want to know how many of the total values were wrong, and by how much. Or, if it's a question of badvalues, which it appears pdl_cmp is saying, how many were there?

So, could I ask you to modify pdl_cmp locally to get it to produce a whichND of the != of the "got" and "expected" values, then share it here? In this context where there are fewer than the "too big to print" number (about 10k), I hope that's reasonable. It would also be valuable to get the indexND of that whichND from got, just to see what came out of the transform.

(I also note that between the IO::FITS being included and not, there is at least a \n on the end of HISTORY that's different)

@dhdeangelis
Copy link

dhdeangelis commented Oct 6, 2024

I did (not calling PDL::IO::FITS here):

sub pdl_cmp {
  my ($g, $e, $l) = @_;

  print "- - - - - - - - - - - - - - - - - - - - - - - - - - - - \n";
  
  # got
  print "got:\n";
  print $g;
  print "whichND: ",whichND($g);
  
  # expected
  print "expected:\n";
  print $e;
  print "whichND: ",whichND($e); 
  
  $_ = PDL->topdl($_) for $g, $e;
  local $Test::Builder::Level = $Test::Builder::Level + 1;
  my $res = all(approx($g, pdl($e), 1.1));
  
  print "result:\n";
  print approx($g, pdl($e), 1.1);
  
  fail("$l: result was BAD value"), return if $res->isbad;
  ok $res, $l or diag "got:\n$g\nexpected:\n$e";
  
  print "\n";
}

got this, posting only tests 6-10 since it is very long otherwise:

> /usr/local/bin/perl proj_transform2.t 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
got:

[
 [116 117 117 117]
 [128 129 125 125]
 [136 137 133 133]
 [144 145 141 141]
]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
expected:
 [116 117 117 117]
 [128 129 125 125]
 [136 137 133 133]
 [144 145 141 141]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]
ok 1 - check ref_ortho for slices[0]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
got:

[
 [180 184 184 188]
 [188 188 192 192]
 [192 196 200 200]
 [196 200 204 208]
]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
expected:
 [180 184 184 188]
 [188 188 192 192]
 [192 196 200 200]
 [196 200 204 208]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]
ok 2 - check ref_ortho for slices[1]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
got:

[
 [188 189 189 189]
 [196 197 197 193]
 [204 205 201 201]
 [208 209 209 209]
]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
expected:
 [188 189 189 189]
 [196 197 197 193]
 [204 205 201 201]
 [208 209 209 209]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]
ok 3 - check ref_ortho for slices[2]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
got:

[
 [173 169 165 161]
 [177 173 169 165]
 [185 181 177 169]
 [189 185 181 173]
]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
expected:
 [173 169 165 161]
 [177 173 169 165]
 [185 181 177 169]
 [189 185 181 173]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]
ok 4 - check ref_ortho for slices[3]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
got:

[
 [241 237 233 225]
 [245 241 237 229]
 [246 242 234 226]
 [238 234 226 218]
]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
expected:
 [241 237 233 225]
 [245 241 237 229]
 [246 242 234 226]
 [238 234 226 218]
whichND: WARNING - list context deprecated. Set $PDL::whichND. Details in pod.whichND: 
[
 [0 0]
 [1 0]
 [2 0]
 [3 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [0 2]
 [1 2]
 [2 2]
 [3 2]
 [0 3]
 [1 3]
 [2 3]
 [3 3]
]
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]
ok 5 - check ref_ortho for slices[4]

1..5

Lots of fishy behavior if for example, I do not print $g it fails, if I print $g it passes.

I am not sure how exactly should I use indexND or what to expect.

@mohawk2
Copy link
Member

mohawk2 commented Oct 8, 2024

Unfortunately all the above does is a whichND on each of the "got" and "expected", telling us which elements of each are true. It's all of them, so that's not so useful. Please can you try with this:

sub pdl_cmp {
  my ($g, $e, $l) = @_;
  print "- - - - - - - - - - - - - - - - - - - - - - - - - - - - \n";
  $_ = PDL->topdl($_) for $g, $e;
  local $Test::Builder::Level = $Test::Builder::Level + 1;
  my $which_close = approx($g, $e, 1.1);
  print "result:\n$which_close\n";
  fail("$l: result was BAD value"), return if any $which_close->isbad;
  (my $bool = ok all($which_close), $l) or diag "got:\n$g\nexpected:\n$e";
  print "whichND of unequal: ",whichND($which_close) if !$bool;
  print "\n";
}

@dhdeangelis
Copy link

Enabling only tests 6-10 passes with 4x4 piddles of ones. Tests 6-10 fail if other tests enabled.

> /usr/local/bin/perl proj_transform2.t
- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 1 - check ref_eqc for slices[0]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 2 - check ref_eqc for slices[1]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 3 - check ref_eqc for slices[2]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 4 - check ref_eqc for slices[3]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 5 - check ref_eqc for slices[4]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
]

not ok 6 - check ref_ortho for slices[0]: result was BAD value
#   Failed test 'check ref_ortho for slices[0]: result was BAD value'
#   at proj_transform2.t line 88.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
]

not ok 7 - check ref_ortho for slices[1]: result was BAD value
#   Failed test 'check ref_ortho for slices[1]: result was BAD value'
#   at proj_transform2.t line 88.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
]

not ok 8 - check ref_ortho for slices[2]: result was BAD value
#   Failed test 'check ref_ortho for slices[2]: result was BAD value'
#   at proj_transform2.t line 88.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
]

not ok 9 - check ref_ortho for slices[3]: result was BAD value
#   Failed test 'check ref_ortho for slices[3]: result was BAD value'
#   at proj_transform2.t line 88.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
 [BAD BAD BAD BAD]
]

not ok 10 - check ref_ortho for slices[4]: result was BAD value
#   Failed test 'check ref_ortho for slices[4]: result was BAD value'
#   at proj_transform2.t line 88.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 11 - check ref_ortho2 for slices[0]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 12 - check ref_ortho2 for slices[1]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 13 - check ref_ortho2 for slices[2]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 14 - check ref_ortho2 for slices[3]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 15 - check ref_ortho2 for slices[4]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 16 - check ref_robin for slices[0]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 17 - check ref_robin for slices[1]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 18 - check ref_robin for slices[2]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 19 - check ref_robin for slices[3]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
result:

[
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]
]

ok 20 - check ref_robin for slices[4]

1..20
# Looks like you failed 5 tests of 20.

@mohawk2
Copy link
Member

mohawk2 commented Oct 9, 2024

So it looks like the effect only happens in ortho, and not if PDL::IO::FITS is loaded. Please could you make it use Data::Dumper; print +Dumper $map->hdr; in the scenario when it fails, and when it doesn't? (EDIT: before running the map that fails, so we can see what map will get passed) The problem specifically looks like PDL::Transform is giving invalid coordinates to the PROJ transform, which is why it returns badvals.

This is likely to be a failure of the handling of FITS headers when A:F:H isn't loaded, so it will be valuable to track it down.

@dhdeangelis
Copy link

So it looks like the effect only happens in ortho, and not if PDL::IO::FITS is loaded.

Exactly

Please could you make it use Data::Dumper; print +Dumper $map->hdr; in the scenario when it fails, and when it doesn't? (EDIT: before running the map that fails, so we can see what map will get passed)

with:

use strict;
use warnings;
use PDL::LiteF;
# use PDL::IO::FITS; # commented out, not used
use PDL::Transform::Proj4;
use PDL::Transform::Cartography;
use Test::More;
use Data::Dumper;

In tests 6-10:

   ###############
   # TESTS 6-10: #
   ###############
   # Get Ortho reference data:
   my @ref_ortho_slices = get_ref_ortho_slices();

   # Check Ortho map against reference:
   my $ortho_opts = "+proj=ortho +ellps=WGS84 +lon_0=-90 +lat_0=40";
   
   print +Dumper $map->hdr;
   
   my $ortho = $map->map( t_proj( proj_params => $ortho_opts ), $map_size );
   foreach my $i ( 0 .. $#slices )
   {
      my $str = $slices[$i];
      my $slice = $ortho->slice($str);
      pdl_cmp($slice, $ref_ortho_slices[$i], "check ref_ortho for slices[$i]");
   }

gives:

$VAR1 = {
          'NAXIS' => '2',
          'NAXIS1' => '128',
          'NAXIS2' => '64',
          'CRVAL1' => '0',
          'CRVAL2' => '0',
          'CRPIX1' => '64.5',
          'CRPIX2' => '32.5',
          'CTYPE1' => 'Longitude',
          'CTYPE2' => 'Latitude',
          'CUNIT1' => 'degrees',
          'CUNIT2' => 'degrees',
          'CDELT1' => '2.8125',
          'CDELT2' => '2.8125',
          'HISTORY' => 'PDL conversion from raster image
',
          'SIMPLE' => 'T'
        };

All test pass then. If 1-5 are disabled, 6-10 pass, but 11-15 fail.

As before: if one chooses to print $ortho, in 6-10, then all tests pass.

@mohawk2
Copy link
Member

mohawk2 commented Oct 11, 2024

@dhdeangelis Thank you! Could you also show the hdr output for when IO::FITS is loaded, so I can see the difference?

@dhdeangelis
Copy link

Could you also show the hdr output for when IO::FITS is loaded, so I can see the difference?

Here it comes. I do not see any difference sadly:

with:

use strict;
use warnings;
use PDL::LiteF;
use PDL::IO::FITS;
use PDL::Transform::Proj4;
use PDL::Transform::Cartography;
use Test::More;
use Data::Dumper;

gives:

$VAR1 = {
          'NAXIS' => '2',
          'NAXIS1' => '128',
          'NAXIS2' => '64',
          'CRVAL1' => '0',
          'CRVAL2' => '0',
          'CRPIX1' => '64.5',
          'CRPIX2' => '32.5',
          'CTYPE1' => 'Longitude',
          'CTYPE2' => 'Latitude',
          'CUNIT1' => 'degrees',
          'CUNIT2' => 'degrees',
          'CDELT1' => '2.8125',
          'CDELT2' => '2.8125',
          'HISTORY' => 'PDL conversion from raster image
',
          'SIMPLE' => 'T'
        };

My general observation is: if we do not use IO::FITS tests will fail, but will pass if we print $map or $ortho.

However ... now, for the first time, I am seeing intermittent behavior in the test results.

@mohawk2
Copy link
Member

mohawk2 commented Oct 14, 2024

That intermittent behaviour might actually be because the PROJ-binding code until extremely recently was using a non-thread-safe API, but for large data inputs (>1e6 elements, such as the 2e6-pixel Earth image) would nevertheless use POSIX threads, which is a recipe for intermittent problems.

To see if I'm right on this, could you first of all try running the test lots of times as it is now, to get a feel for how often it fails? Then, could you set the environment variable PDL_AUTOPTHREAD_TARG to 1 (thereby disabling multi-thread behaviour) and seeing if the failure rate changes to zero?

@mohawk2
Copy link
Member

mohawk2 commented Oct 22, 2024

@shawnlaffan Do you feel this problem is now solved? If so, are you happy to close the issue?

@shawnlaffan
Copy link
Contributor Author

I cannot test on the original system due to an Alien::proj/Alien::Build issue with mixed system/share installs. Despite Alien::proj being a share install, PDL is being linked to the system installation of Proj due to how the libs are stored and reported by Alien::Build/Base, and now won't build.

Can't load '/home/shawn/git/pdl/Libtmp/Transform/Proj4/../../../blib/arch/auto/PDL/Transform/Proj4/Proj4.so' for module PDL::Transform::Proj4: /home/shawn/git/pdl/Libtmp/Transform/Proj4/../../../blib/arch/auto/PDL/Transform/Proj4/Proj4.so: undefined symbol: proj_degree_output at /home/shawn/perl5/perlbrew/perls/perl-5.40.0/lib/5.40.0/x86_64-linux/DynaLoader.pm line 206.
 at t/gis_proj.t line 10.

This is because the linked Proj library on the system is version 6.3.1, and proj_degree_output was add in Proj 7.1.
https://proj.org/en/9.4/development/reference/functions.html#c.proj_degree_output

Fixing the dynamic libs is an Alien::proj/Alien::Build problem, but PDL will still break for a system Alien::proj where Proj is earlier than 7.1. Either PDL needs to check for proj_degree_output or require a minimum of Proj version 7. FWIW, Ubuntu 20.04 provides Proj 6.3.1, and is not EOL until April 2025.

Also FWIW, the tests pass on an Ubuntu 24.04 instance without a system install of Alien::proj, but also passed before all the related PDL changes.

@shawnlaffan
Copy link
Contributor Author

Fixing the dynamic libs is an Alien::proj/Alien::Build problem, but PDL will still break for a system Alien::proj where Proj is earlier than 7.1. Either PDL needs to check for proj_degree_output or require a minimum of Proj version 7. FWIW, Ubuntu 20.04 provides Proj 6.3.1, and is not EOL until April 2025.

I could also bump the minimum version for Alien::proj to be Proj 7 or higher. That won't fix the dynamic libs issue but will ensure proj_degree_output is available. (Alien::gdal already requires a minimum GDAL version higher than that provided by Ubuntu 20.04).

@mohawk2
Copy link
Member

mohawk2 commented Oct 23, 2024

I feel it's pretty important to get the units correct, and the proj_degree_output stuff is necessary to distinguish between degrees/radians, and metres. Would you mind making Alien::proj only do a system install if PROJ is >= 7/has proj_degree_output?

EDIT Or, I could make the units stuff only available if >= 7 - do you have a view?

@shawnlaffan
Copy link
Contributor Author

I've set it to 7.1 in shawnlaffan/perl-alien-proj@7d1296e

Once I get CI sorted I'll release a new Alien::proj

@shawnlaffan
Copy link
Contributor Author

Alien::Proj 1.28 is now on CPAN.
https://metacpan.org/release/SLAFFAN/Alien-proj-1.28

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Oct 23, 2024

Looping back to the build issues (edit: in #498 (comment)), I now think that's caused by PDL or EUMM. The rpath of the Proj4.so file links directly to /usr/lib/x86_64-linux-gnu and thus does not see the target version that lives under Alien::proj->dist_dir . '/lib'

patchelf --print-rpath blib/arch/auto/PDL/Transform/Proj4/Proj4.so
/usr/lib/x86_64-linux-gnu

This seems to be due to a line in the generated Makefile that sets the LD_RUNPATH:

LD_RUN_PATH = /usr/lib/x86_64-linux-gnu

That variable should point to Alien::proj->dist_dir . '/lib' when Alien::proj->install_type eq 'share'.

I am not sure how or where to set that, though, and there is only one place in the PDL code base that uses LD_RUN_PATH:

my $ld_cmd = ( $^O =~ /MSWin|android/i ? ' ' : 'LD_RUN_PATH="" ');

Another approach is to add -Wl,-rpath=/path/to/share/lib to the compilation flags. Again, I'm not sure how to do this.

One could also set $ENV{LD_LIB_PATH} to include Alien::proj->dist_dir . '/lib' but I would not expect that to be desirable.

@mohawk2
Copy link
Member

mohawk2 commented Oct 23, 2024

I'm trying to figure out a 6.3-compatible solution, having asked for help on OSGeo/PROJ#4217 - if that works, then it might solve the immediate problem.

@shawnlaffan
Copy link
Contributor Author

The build issue should be fixed by shawnlaffan/perl-alien-proj@ed072d4

That stops system directories being added to the lib search path, allowing the Alien share builds to be found before any system versions.

@shawnlaffan
Copy link
Contributor Author

The build issue should be fixed by shawnlaffan/perl-alien-proj@ed072d4

Now released as part of Alien::proj 1.29: https://metacpan.org/release/SLAFFAN/Alien-proj-1.29

@mohawk2
Copy link
Member

mohawk2 commented Oct 24, 2024

Does that mean you consider this issue solved?

@dhdeangelis
Copy link

That intermittent behaviour might actually be because the PROJ-binding code until extremely recently was using a non-thread-safe API, but for large data inputs (>1e6 elements, such as the 2e6-pixel Earth image) would nevertheless use POSIX threads, which is a recipe for intermittent problems.

To see if I'm right on this, could you first of all try running the test lots of times as it is now, to get a feel for how often it fails? Then, could you set the environment variable PDL_AUTOPTHREAD_TARG to 1 (thereby disabling multi-thread behaviour) and seeing if the failure rate changes to zero?

@mohawk2 this did not make a difference. Still printing interim results is the way to avoid failures. Even after updating Alien::proj to 1.29.

@mohawk2
Copy link
Member

mohawk2 commented Oct 24, 2024

@mohawk2 this did not make a difference. Still printing interim results is the way to avoid failures. Even after updating Alien::proj to 1.29.

Thank you. Is there a way I could login to that machine to investigate more directly?

@dhdeangelis
Copy link

Thank you. Is there a way I could login to that machine to investigate more directly?

No

@mohawk2
Copy link
Member

mohawk2 commented Oct 24, 2024

Thank you. Is there a way I could login to that machine to investigate more directly?

No

Then my ability to debug this further will be limited. Can you confirm whether the latest master (with the adjusted tests) still fails?

@dhdeangelis
Copy link

Using the latest master the test proj_transform2.t in 2.093 passes without failure. This does not seem to be intermittent success. I guess the issue can be closed. Thank you @mohawk2 and @shawnlaffan .

@shawnlaffan
Copy link
Contributor Author

Does that mean you consider this issue solved?

The tests all pass for me now so on that basis it can be closed.

The one remaining component is your idea to support Proj 6.3.1. Is that still on the cards?

@mohawk2
Copy link
Member

mohawk2 commented Oct 24, 2024

Does that mean you consider this issue solved?

The tests all pass for me now so on that basis it can be closed.

The one remaining component is your idea to support Proj 6.3.1. Is that still on the cards?

Let's give the OSGeo folks a bit longer. If it turns out it is possible, we could remove the increased need for share installs.

@mohawk2
Copy link
Member

mohawk2 commented Oct 29, 2024

@shawnlaffan I think they've had long enough. Unfortunately we'll have to do a bit more share installing on older Ubuntu! Could you close this? That way you can reopen if further problems arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants