IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39926


Ignore:
Timestamp:
Jan 6, 2017, 11:30:10 AM (9 years ago)
Author:
eugene
Message:

merging changes from czw dev branch (compare with r39924)

Location:
trunk
Files:
3 deleted
155 edited
18 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Nebulous-Server/Build.PL

    r39663 r39926  
    4848        bin/neb-voladd
    4949        bin/neb-voladm
     50        bin/neb-aliasadd
    5051        bin/neb-insedit
    5152        bin/neb-host
  • trunk/Nebulous-Server/bin/neb-cabadd

    r26292 r39926  
    1919use Pod::Usage qw( pod2usage );
    2020
    21 my ($db, $dbhost, $dbuser, $dbpass, $cname, $location);
     21my ($db, $dbhost, $dbuser, $dbpass, $cname, $location, $site_id, $update, $cab_id);
    2222
    2323$db     = $ENV{'NEB_DB'} unless $db;
     
    3333    'cname|n=s'         => \$cname,
    3434    'location|l=s'      => \$location,
     35    'site_id|s=s'       => \$site_id,
     36    'cab_id=s'          => \$cab_id,
     37    'update|u'          => \$update,
    3538) || pod2usage( 2 );
    3639
    3740pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    38 pod2usage( -msg => "Required options: --db --user --pass --cname", -exitval => 2 )
    39     unless $db && $dbuser && $dbpass && $cname;
     41pod2usage( -msg => "Required options: --db --user --pass --cname --site_id", -exitval => 2 )
     42    unless $db && $dbuser && $dbpass && $cname && $site_id;
    4043
    4144my $dbh = DBI->connect(
     
    5255my $sql = Nebulous::Server::SQL->new();
    5356
    54 print "Adding cabinet...";
    55 
    56 my $query = $dbh->prepare( $sql->new_cabinet );
    57 $query->execute( $cname, $location);
    58 
    59 print " OK\n";
    60 
     57if (defined($update)) {
     58    unless ($cname && $location && $site_id && $cab_id) {
     59        pod2usage( -msg => "Required options for update: --db --user --pass --cname --site_id --location --cab_id", -exitval => 2 );
     60    }
     61    print "Updating cabinet...";
     62    my $query = $dbh->prepare( $sql->update_cabinet );
     63    # Check query:
     64#        UPDATE cabinet SET
     65#           location = ?,
     66#           name     = ?,
     67#           site_id  = ?
     68#        WHERE cab_id = ?
     69
     70    $query->execute( $location, $cname, $site_id, $cab_id );
     71   
     72    print "OK\n";
     73
     74}
     75else {
     76    print "Adding cabinet...";
     77   
     78    my $query = $dbh->prepare( $sql->new_cabinet );
     79    $query->execute( $cname, $location, $site_id);
     80   
     81    print " OK\n";
     82}
    6183__END__
    6284
     
    6991=head1 SYNOPSIS
    7092
    71     neb-cabadd --cname <cabinet name> --location <cabinet location>
     93    neb-cabadd --cname <cabinet name> --location <cabinet location> --site_id <site_id>
    7294    [--db <database>] [--user <username>] [--pass <password>] [--host <hostname]
    7395
     
    89111
    90112Description of the location of the cabinet.
     113
     114=item * --site_id <site_id>
     115
     116Numerical value of the location's site.  Default = 0.
    91117
    92118=item * --db|-d <database>
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r31370 r39926  
    17531753}
    17541754
    1755 sub find_instances
     1755sub find_instances_old
    17561756{
    17571757    my $self = shift;
     
    18201820            # ext_id, name, available
    18211821            my $rows = $query->execute($key->path, $vol_name, 1);
     1822            unless ($rows > 0) {
     1823                $query->finish;
     1824                die("no instances on storage volume or volume is not avaiable for key: $key volume: $vol_name");
     1825            }
     1826        } else {
     1827            $query = $db->prepare_cached( $sql->get_object_instances );
     1828            my $rows;
     1829            # ext_id, available
     1830            if (defined($find_invalid)) {
     1831                $rows = $query->execute($key->path, 0);
     1832            }
     1833            else {
     1834                $rows = $query->execute($key->path, 1);
     1835            }
     1836            unless ($rows > 0) {
     1837                $query->finish;
     1838                die("no instances available for key: $key");
     1839            }
     1840        }
     1841
     1842        while (my $row = $query->fetchrow_hashref) {
     1843            my $instance = $row->{ 'uri' };
     1844            push @locations, $instance if $instance;
     1845        }
     1846    };
     1847    if ($@) {
     1848        $db->rollback;
     1849        # handle soft volumes
     1850        if (defined $vol_name and not defined $key->hard_volume) {
     1851            $log->debug("retrying with 'any' volume");
     1852            return $self->find_instances($key->path, 'any');
     1853        }
     1854        $log->logdie("database error: $@");
     1855    }
     1856
     1857    # XXX remove this?
     1858    $log->logdie("no instances found") unless (scalar @locations);
     1859
     1860    $log->debug("found: @locations");
     1861
     1862    $log->debug("leaving");
     1863
     1864    return \@locations;
     1865}
     1866
     1867#sub find_instances_by_proximity
     1868sub find_instances
     1869{
     1870    my $self = shift;
     1871
     1872    my $log = $self->log;
     1873    $log->debug("entered - @_");
     1874
     1875    my ($key, $vol_name, $find_invalid) = validate_pos(@_,
     1876        {
     1877            type        => SCALAR,
     1878            callbacks   => {
     1879                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     1880            },
     1881        },
     1882        {
     1883            type        => SCALAR|UNDEF,
     1884#            callbacks   => {
     1885#                # check that the volume name requested is valid
     1886#                'is valid volume name' => sub {
     1887#                    return 1 if not defined $_[0];
     1888#                    $self->_is_valid_volume_name($_[0])
     1889#                },
     1890#            },
     1891            optional    => 1,
     1892        },
     1893        {
     1894            # find_invalid
     1895            type        => SCALAR|UNDEF,
     1896            optional    => 1,
     1897        },
     1898    );
     1899
     1900    my $sql = $self->sql;
     1901
     1902#    unless ($key) {
     1903#        $log->warn("key was undefined after validate_pos(), trying again...");
     1904#        return $self->find_instances(@_);
     1905#    }
     1906
     1907    # vol_name overrides the key implied volume
     1908    my ($h_vol_id, $h_cab_id, $h_site_id);
     1909    eval {
     1910        $key = parse_neb_key($key, $vol_name);
     1911    };
     1912    $log->logdie("$@") if $@;
     1913    $vol_name = $key->volume;
     1914
     1915    my $db  = $self->db($key);
     1916
     1917    # Convert possible alias to real volume.
     1918    if (defined $vol_name) {
     1919        my ($tmp_vol_id, $tmp_name, $tmp_host, $tmp_path);
     1920        eval {
     1921            my $query = $db->prepare_cached( $sql->get_volume_by_alias );
     1922            $query->execute( $vol_name );
     1923            ($tmp_vol_id, $tmp_name, $tmp_host, $tmp_path) = $query->fetchrow_array;
     1924            $query->finish;
     1925        };
     1926        $log->logdie("$@") if $@;
     1927#       $log->warn("CZW: find_instance: deref alias: $vol_name => $tmp_vol_id $tmp_name $tmp_host $tmp_path (key vol: $key" . $key->volume . ")");
     1928        if (defined $tmp_vol_id and defined $tmp_name and defined $tmp_host and defined $tmp_path) {
     1929            if ($tmp_name ne $vol_name) {
     1930                $vol_name = $tmp_name;
     1931#               $key->volume = $vol_name;
     1932            }
     1933        }
     1934
     1935
     1936    }
     1937
     1938    # the key's volume can't be validiated on input for this method so we have
     1939    # to check it after parsing the key
     1940    if (defined $vol_name
     1941        and not $self->_is_valid_volume_name($key, $vol_name)) {
     1942        if ($key->hard_volume) {
     1943            $log->logdie("$vol_name is not a valid volume name");
     1944        } else {
     1945            $log->warn( "$vol_name is not a known volume name" );
     1946            $vol_name = undef;
     1947        }
     1948    }
     1949
     1950    # Get the host volume information encoded in the vol_name.
     1951    # I am unhappy that we have three different if(defined($vol_name)) entries, but I don't see a better way.
     1952#    my ($h_vol_id, $h_cab_id, $h_site_id);
     1953    if (defined $vol_name) {
     1954        eval {
     1955            my $query = $db->prepare_cached( $sql->get_site_info_by_name );
     1956            $query->execute( $vol_name );
     1957            ($h_vol_id, $h_cab_id, $h_site_id) = $query->fetchrow_array;
     1958            $query->finish;
     1959        };
     1960        $log->logdie("$@") if $@;
     1961
     1962        unless(defined $h_vol_id and defined $h_cab_id and defined $h_site_id) {
     1963            $vol_name = undef;
     1964        }
     1965    }
     1966
     1967    my @locations;
     1968    eval {
     1969        my $query;
     1970        if ($vol_name && $h_vol_id && $h_cab_id && $h_site_id) {
     1971            $query = $db->prepare_cached( $sql->get_object_instances_by_proximity );
     1972            # ext_id, name, available
     1973            # host_vol_id host_cab_id host_site_id ext_id available
     1974            my $rows = $query->execute($h_vol_id, $h_cab_id, $h_site_id, $key->path, 1);
    18221975            unless ($rows > 0) {
    18231976                $query->finish;
     
    23412494    my $db  = $self->db($key);
    23422495
    2343     my ($vol_id, $vol_host, $vol_path, $xattr, $forbidden_cabinet);
     2496    my ($vol_id, $vol_host, $vol_path, $xattr, $forbidden_cabinet, $forbidden_site);
    23442497    eval {
    23452498        my $rows;
     
    23522505        }
    23532506        if ($rows == 1) {
    2354             ($forbidden_cabinet) = $query->fetchrow_array;
     2507            ($forbidden_cabinet, $forbidden_site) = $query->fetchrow_array;
    23552508            unless (defined($forbidden_cabinet)) {
    23562509                $forbidden_cabinet = 0;
     2510            }
     2511            unless (defined($forbidden_site)) {
     2512                $forbidden_site = 0;
    23572513            }
    23582514            $query->finish;
     
    23602516        else {
    23612517            $forbidden_cabinet = 0;
     2518            $forbidden_site    = 0;
    23622519            $query->finish;
    23632520        }
     
    23662523        $query = $db->prepare_cached( $sql->get_replication_volume_for_ext_id );
    23672524        # ext_id, %free, avaiable, allocate
    2368         $rows = $query->execute($key->path, $max_used_space, 1, 1, $forbidden_cabinet, $topfew_count);
     2525        $rows = $query->execute($key->path, $max_used_space, 1, 1, $forbidden_cabinet, $forbidden_site, $topfew_count);
    23692526        # XXX destinguish between non-existant and unaviable
    23702527        unless ($rows > 0) {
    23712528            $query->finish;
    2372             die("can't find a suitable storage volume to replicate $key to");
     2529            # CZW: 2016-08-23 This wasn't right.  If we don't get an entry, we may have been too strict.
     2530            #      I'm not fully convinced this is complete, as we may want to back out the cabinet criterion as well.
     2531            #      In any case, I don't think we're generally in the situation where replication can't find a host.
     2532            $rows = $query->execute($key->path, $max_used_space, 1, 1, $forbidden_cabinet, 0, $topfew_count);
     2533            unless ($rows > 0) {
     2534                die("can't find a suitable storage volume to replicate $key to");
     2535            }
    23732536        }
    23742537        # when matching by name we shouldn't ever match more than once
     
    24902653    $log->logdie("database error: $@") if $@;
    24912654
     2655#    $log->warn("CZW: $vol_id $vol_path for >>$vol_name<<");
    24922656    if (defined $vol_id and defined $vol_path) {
    24932657        $log->debug( "found volume name $vol_name" );
    24942658        $log->debug( "leaving" );
     2659#       $log->warn("CZW: $vol_id $vol_path for >>$vol_name<<");
    24952660        return 1;
    24962661    }
  • trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm

    r34764 r39926  
    250250            AND mountedvol.available = ?
    251251    },
     252    get_object_instances_by_proximity  => qq{
     253        SELECT
     254            storage_object.so_id,
     255            uri,
     256            mountedvol.available,
     257            vol_id,
     258            cab_id,
     259            (ABS(vol_id - ?) + 20 * ABS(cab_id - ?) + 100 * ABS(site_id - ?)) AS vol_idx
     260        FROM storage_object
     261        JOIN instance
     262            USING (so_id)
     263        JOIN mountedvol
     264            USING(vol_id)
     265        JOIN volume
     266            USING(vol_id)
     267        JOIN cabinet
     268            USING(cab_id)
     269        WHERE ext_id = ?
     270          AND mountedvol.available = ?
     271        ORDER BY vol_idx ASC
     272    },
    252273    get_object_instances_by_vol_name => qq{
    253274        SELECT
     
    301322    get_cabinets_for_ext_id            => qq{
    302323        SELECT DISTINCT
    303             cab_id
     324            volume.cab_id, site_id
    304325        FROM instance
    305         JOIN volume ON instance.vol_id = volume.vol_id
     326        JOIN volume ON (instance.vol_id = volume.vol_id)
     327        JOIN cabinet ON (volume.cab_id  = cabinet.cab_id)
    306328        JOIN storage_object USING(so_id)
    307329        WHERE ext_id = ?
     
    317339        FROM mountedvol AS m
    318340        JOIN volume AS v USING(vol_id)
     341        JOIN cabinet AS c USING(cab_id)
    319342        LEFT JOIN (
    320343                   SELECT
     
    336359             AND m.available = ?
    337360             AND m.allocate = ?
    338              AND m.xattr = 0
     361--             AND m.xattr = 0
    339362             AND ( (v.cab_id IS NULL) ||
    340363                   (v.cab_id != ?) )
     364             AND ( (c.site_id IS NULL) ||
     365                   (c.site_id != ?) )
    341366         ORDER BY free DESC
    342367         LIMIT ?) as topfew
     
    366391    },
    367392    new_cabinet         => qq{
    368         INSERT INTO cabinet (name, location, cab_id)
    369         VALUES (?, ?, NULL)
     393        INSERT INTO cabinet (name, location, site_id, cab_id)
     394        VALUES (?, ?, ?, NULL)
     395    },
     396    update_cabinet      => qq{
     397        UPDATE cabinet SET
     398           location = ?,
     399           name     = ?,
     400           site_id  = ?
     401        WHERE cab_id = ?
    370402    },
    371403    new_volume          => qq{
    372404        INSERT INTO volume (name, host, path, allocate, available, xattr, mountpoint, cab_id, note)
    373405        VALUES (?, ?, ?, TRUE, TRUE, FALSE, ?, NULL, ?)
     406    },
     407    new_alias          => qq{
     408        INSERT INTO aliasvol (alias_id, alias, name, vol_id)
     409        VALUES (NULL, ?, ?, ?)
     410    },
     411    update_alias       => qq{
     412        UPDATE alias SET
     413          vol_id = ?,
     414          name   = ?
     415        WHERE alias_id = ?
     416        AND   alias    = ?
    374417    },
    375418    get_volume_by_name => qq{
     
    377420        FROM volume
    378421        WHERE name = ?
     422    },
     423    get_volume_by_alias => qq{
     424        SELECT vol_id, name, host, path
     425        FROM aliasvol
     426        JOIN volume USING(vol_id,name)
     427        WHERE alias = ?
     428    },
     429    get_site_info_by_name => qq{
     430        SELECT vol_id, cab_id, site_id
     431        FROM volume
     432        JOIN cabinet USING(cab_id)
     433        WHERE volume.name = ?
    379434    },
    380435    get_volumes => qq{
     
    676731    cab_id INT NOT NULL AUTO_INCREMENT,
    677732    name VARCHAR(255) NOT NULL,
     733    site_id INT NOT NULL DEFAULT 0,
    678734    location VARCHAR(255),
    679735    PRIMARY KEY(cab_id),
    680736    UNIQUE KEY(name),
     737    KEY (site_id),
    681738    KEY (location)
    682739) ENGINE=innodb DEFAULT CHARSET=latin1;
     
    735792###
    736793
     794CREATE TABLE aliasvol (
     795    alias_id INT NOT NULL AUTO_INCREMENT,
     796    alias VARCHAR(255) NOT NULL,
     797    name  VARCHAR(255) NOT NULL,
     798    vol_id INT NOT NULL,
     799    PRIMARY KEY(alias_id),
     800    KEY(alias),
     801    KEY(name),
     802    FOREIGN KEY(vol_id) REFERENCES volume(vol_id)
     803) ENGINE=innodb DEFAULT CHARSET=latin1;
     804
     805###
     806
    737807CREATE TABLE instance (
    738808    ins_id BIGINT NOT NULL AUTO_INCREMENT,
  • trunk/Nebulous/bin/neb-repair

    r39506 r39926  
    167167    my $name = shift;                # Filename for which to get the scheme
    168168    my ($scheme) = $name =~ /^(path|neb|file):/; # The scheme, e.g., file://, path://
    169     if undef $scheme { $scheme = "none"; }
     169#    if undef $scheme { $scheme = "none"; }
    170170    # $scheme may be undef if the input doesn't contain one of the above recognised schemes
    171171    unless (defined($scheme)) { $scheme = "none"; }
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r31850 r39926  
    1818use Params::Validate qw( validate validate_pos SCALAR UNDEF BOOLEAN );
    1919#use SOAP::Lite +trace => [qw( debug )];
     20use Sys::Hostname;
    2021use SOAP::Lite;
    2122use Time::HiRes qw( sleep );
     
    858859
    859860    $log->debug( "entered - @_" );
     861   
     862    unless(defined($params[0])) {
     863        $params[0] = hostname() . ".0";
     864#       print STDERR "Setting host to $params[0]\n";
     865    }
    860866
    861867    my $response = $self->{ 'server' }->find_instances( $key, @params );
     
    980986    $log->debug( "entered - @_" );
    981987
     988    my $find_volume = hostname() . ".0";
     989    $params[0] = $find_volume;
    982990    my $locations = $self->find_instances( $key, @params );
    983991    unless (defined $locations) {
  • trunk/Nebulous/nebclient/src/nebclient.c

    r25000 r39926  
    529529        return NULL;
    530530    }
     531
     532    // Construct a dummy volume name to allow nebulous to find the
     533    // closest instance available.
     534    char hostname[256];
     535    char volname[260];
     536
     537    int v;
     538
     539    v = gethostname(hostname,256);
     540    //    fprintf(stderr, "%s %d\n", hostname, v);
     541/*     printf("%s %d\n",hostname,v); */
     542    if (v) {
     543      nebSetErr(server, "failed to construct hostname");
     544      return NULL;
     545    }
     546    snprintf(volname,260, "%s.0", hostname);
    531547   
    532     nebObjectInstances *locations = nebFindInstances(server, key, NULL);
     548    nebObjectInstances *locations = nebFindInstances(server, key, volname);
    533549    if (!locations) {
    534550        if (!strstr(nebErr(server), "no instances on storage volume")) {
  • trunk/Ohana

  • trunk/Ohana/Makefile.in

    r38473 r39926  
    138138
    139139rebuild:
     140        @date
    140141        $(MAKE) clean
    141142        $(MAKE) install
     143        @date
    142144
    143145# standard rules: targets are foo, foo.clean, foo.install, foo.dist
  • trunk/Ohana/src/addstar/Makefile

    r39496 r39926  
    2525load2mass    : $(BIN)/load2mass.$(ARCH)
    2626loadgalphot  : $(BIN)/loadgalphot.$(ARCH)
     27loadgaia     : $(BIN)/loadgaia.$(ARCH)
    2728loadstarpar  : $(BIN)/loadstarpar.$(ARCH)
    2829loadstarpar_client : $(BIN)/loadstarpar_client.$(ARCH)
     
    4243# programs in 'SERVER' use the client-server concept and are out of date
    4344
    44 INSTALL = addstar addstar_client sedstar loadgalphot loadstarpar loadstarpar_client setobjflags setobjflags_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell load2mass loadwise loadtycho loadbsc loadsupercos
     45INSTALL = addstar addstar_client sedstar loadgalphot loadgaia loadstarpar loadstarpar_client setobjflags setobjflags_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell load2mass loadwise loadtycho loadbsc loadsupercos
    4546SERVER  = addstarc addstard addstart
    4647
     
    267268$(SRC)/psps_ids.$(ARCH).o
    268269
    269 # $(SRC)/SkyRegionUtils.$(ARCH).o
    270 # $(SRC)/loadstarpar_io.$(ARCH).o
    271 # $(SRC)/loadgalphot_remote_hosts.$(ARCH).o
    272 # $(SRC)/loadgalphot_save_remote.$(ARCH).o
     270LOAD-GAIA = \
     271$(SRC)/loadgaia.$(ARCH).o \
     272$(SRC)/ConfigInit.$(ARCH).o \
     273$(SRC)/SetSignals.$(ARCH).o \
     274$(SRC)/Shutdown.$(ARCH).o \
     275$(SRC)/args_loadgaia.$(ARCH).o \
     276$(SRC)/find_matches_gaia.$(ARCH).o \
     277$(SRC)/loadgaia_catalog.$(ARCH).o \
     278$(SRC)/loadgaia_make_subset.$(ARCH).o \
     279$(SRC)/loadgaia_readstars.$(ARCH).o \
     280$(SRC)/loadgaia_table.$(ARCH).o \
     281$(SRC)/resort_catalog.$(ARCH).o \
     282$(SRC)/build_links.$(ARCH).o \
     283$(SRC)/strhash.$(ARCH).o \
     284$(SRC)/sortIDs.$(ARCH).o \
     285$(SRC)/psps_ids.$(ARCH).o
    273286
    274287LOAD-STARPAR = \
     
    493506$(LOAD-2MASS)          : $(INC)/addstar.h $(INC)/2mass.h
    494507$(LOAD-GALPHOT)        : $(INC)/addstar.h $(INC)/loadgalphot.h
     508$(LOAD-GAIA)           : $(INC)/addstar.h $(INC)/gaia.h
    495509$(LOAD-STARPAR)        : $(INC)/addstar.h $(INC)/loadstarpar.h
    496510$(LOAD-STARPAR-CLIENT) : $(INC)/addstar.h $(INC)/loadstarpar.h
     
    514528$(BIN)/loadbsc.$(ARCH)        : $(LOAD-BSC)
    515529$(BIN)/loadgalphot.$(ARCH)    : $(LOAD-GALPHOT)
     530$(BIN)/loadgaia.$(ARCH)       : $(LOAD-GAIA)
    516531$(BIN)/loadstarpar.$(ARCH)    : $(LOAD-STARPAR)
    517532$(BIN)/loadstarpar_client.$(ARCH) : $(LOAD-STARPAR-CLIENT)
  • trunk/Ohana/src/addstar/src/psps_ids.c

    r34701 r39926  
    4242
    4343    uint64_t part1, part2, part3;
    44     part1 = (uint64_t)( izone  * 10000000000000LL) ;
     44    part1 = (uint64_t)( izone  * 10000000000000LL) ; // 10,000,000,000,000
    4545    part2 = ((uint64_t)(ra * 1000000.)) * 10000 ; // 0 - 360*1e6 = 3.6e8 (< 29 bits)
    4646    part3 = (int) (zresid * 10000.0) ; // 0 - 10000 (1 bit == 30/10000 arcsec) (< 14 bits)
     
    4848    return part1 + part2 + part3;
    4949}
     50
     51// 10 000 000 000 000
  • trunk/Ohana/src/delstar/include/delstar.h

    r39692 r39926  
    9595int   SAVE_DELETES;
    9696int   SKIP_IMAGES;
     97char *BACKUP_EXTNAME;
    9798
    9899time_t    START;
     
    111112
    112113// for DELETE_MEASURES_BY_MATCH, these are the ranges to delete:
     114int DELETE_MIN_DET_ID;
     115int DELETE_MAX_DET_ID;
     116int DELETE_MIN_CAT_ID;
     117int DELETE_MAX_CAT_ID;
     118
    113119int DELETE_MIN_IMAGE_ID;
    114120int DELETE_MAX_IMAGE_ID;
     
    118124int DELETE_MIN_TIME;
    119125int DELETE_MAX_TIME;
    120 
    121126
    122127/*** delstar prototypes ***/
  • trunk/Ohana/src/delstar/src/args.c

    r39692 r39926  
    202202  }
    203203
     204  DELETE_MIN_DET_ID = 0;
     205  DELETE_MAX_DET_ID = 0;
     206  DELETE_MIN_CAT_ID = 0;
     207  DELETE_MAX_CAT_ID = 0;
    204208  DELETE_MIN_IMAGE_ID = 0;
    205209  DELETE_MAX_IMAGE_ID = 0;
     
    209213  DELETE_MAX_TIME = 0;
    210214
     215  if ((N = get_argument (argc, argv, "-delete-min-detID")))  { remove_argument (N, &argc, argv); DELETE_MIN_DET_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     216  if ((N = get_argument (argc, argv, "-delete-max-detID")))  { remove_argument (N, &argc, argv); DELETE_MAX_DET_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     217  if ((N = get_argument (argc, argv, "-delete-min-catID")))  { remove_argument (N, &argc, argv); DELETE_MIN_CAT_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     218  if ((N = get_argument (argc, argv, "-delete-max-catID")))  { remove_argument (N, &argc, argv); DELETE_MAX_CAT_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
    211219  if ((N = get_argument (argc, argv, "-delete-min-imageID")))  { remove_argument (N, &argc, argv); DELETE_MIN_IMAGE_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
    212220  if ((N = get_argument (argc, argv, "-delete-max-imageID")))  { remove_argument (N, &argc, argv); DELETE_MAX_IMAGE_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     
    221229    remove_argument (N, &argc, argv);
    222230  }
     231
     232  BACKUP_EXTNAME = NULL;
     233  if ((N = get_argument (argc, argv, "-backup-extname"))) {
     234    remove_argument (N, &argc, argv);
     235    BACKUP_EXTNAME = strcreate (argv[N]);
     236    remove_argument (N, &argc, argv);
     237  }
     238  if (!BACKUP_EXTNAME) BACKUP_EXTNAME = strcreate (".bck");
     239
    223240  SAVE_DELETES = FALSE;
    224241  if ((N = get_argument (argc, argv, "-save-deletes"))) {
     
    471488    remove_argument (N, &argc, argv);
    472489  }
     490
    473491  if ((N = get_argument (argc, argv, "-delete-measures-by-match"))) {
    474492    if (MODE != MODE_NONE) usage();
     
    477495    SKIP_IMAGES = TRUE; // we do not need to load the images for -dup-measures
    478496  }
     497
     498  DELETE_MIN_DET_ID = 0;
     499  DELETE_MAX_DET_ID = 0;
     500  DELETE_MIN_CAT_ID = 0;
     501  DELETE_MAX_CAT_ID = 0;
    479502  DELETE_MIN_IMAGE_ID = 0;
    480503  DELETE_MAX_IMAGE_ID = 0;
     
    484507  DELETE_MAX_TIME = 0;
    485508
     509  if ((N = get_argument (argc, argv, "-delete-min-detID")))  { remove_argument (N, &argc, argv); DELETE_MIN_DET_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     510  if ((N = get_argument (argc, argv, "-delete-max-detID")))  { remove_argument (N, &argc, argv); DELETE_MAX_DET_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     511  if ((N = get_argument (argc, argv, "-delete-min-catID")))  { remove_argument (N, &argc, argv); DELETE_MIN_CAT_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     512  if ((N = get_argument (argc, argv, "-delete-max-catID")))  { remove_argument (N, &argc, argv); DELETE_MAX_CAT_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
    486513  if ((N = get_argument (argc, argv, "-delete-min-imageID")))  { remove_argument (N, &argc, argv); DELETE_MIN_IMAGE_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
    487514  if ((N = get_argument (argc, argv, "-delete-max-imageID")))  { remove_argument (N, &argc, argv); DELETE_MAX_IMAGE_ID = atoi(argv[N]); remove_argument (N, &argc, argv); }
     
    496523    remove_argument (N, &argc, argv);
    497524  }
     525  BACKUP_EXTNAME = NULL;
     526  if ((N = get_argument (argc, argv, "-backup-extname"))) {
     527    remove_argument (N, &argc, argv);
     528    BACKUP_EXTNAME = strcreate (argv[N]);
     529    remove_argument (N, &argc, argv);
     530  }
     531  if (!BACKUP_EXTNAME) BACKUP_EXTNAME = strcreate (".bck");
    498532
    499533  if ((N = get_argument (argc, argv, "-fix-LAP"))) {
  • trunk/Ohana/src/delstar/src/delete_duplicate_measures.c

    r39692 r39926  
    111111
    112112    // save backup of original cpm file
    113     if (!dvo_catalog_subset_backup (&catalog, ".dlx")) {
     113    if (!dvo_catalog_subset_backup (&catalog, ".dlz")) {
    114114      fprintf (stderr, "ERROR: failed to make backup cpt table for catalog %s\n", catalog.filename);
    115115      exit (1);
    116116    }
    117     if (!dvo_catalog_subset_backup (catalog.measure_catalog, ".d1x")) {
     117    if (!dvo_catalog_subset_backup (catalog.measure_catalog, ".d1z")) {
    118118      fprintf (stderr, "ERROR: failed to make backup cpm table for catalog %s\n", catalog.filename);
    119119      exit (1);
    120120    }
    121     if (!dvo_catalog_subset_backup (catalog.secfilt_catalog, ".dlx")) {
     121    if (!dvo_catalog_subset_backup (catalog.secfilt_catalog, ".dlz")) {
    122122      fprintf (stderr, "ERROR: failed to make backup cps table for catalog %s\n", catalog.filename);
    123123      exit (1);
     
    377377  if (SAVE_DUPLICATES) {
    378378    char savename[DVO_MAX_PATH];
    379     snprintf (savename, DVO_MAX_PATH, "%s.save.0912", catalog->filename);
     379    snprintf (savename, DVO_MAX_PATH, "%s.save.0914", catalog->filename);
    380380    struct stat filestat;
    381381    int myStatus = stat (savename, &filestat);
  • trunk/Ohana/src/delstar/src/delete_measures_by_match.c

    r39692 r39926  
    1313
    1414  int validOptions = FALSE;
     15  validOptions |= DELETE_MAX_CAT_ID;
     16  validOptions |= DELETE_MIN_CAT_ID;
     17  validOptions |= DELETE_MAX_DET_ID;
     18  validOptions |= DELETE_MIN_DET_ID;
    1519  validOptions |= DELETE_MAX_IMAGE_ID;
    1620  validOptions |= DELETE_MIN_IMAGE_ID;
     
    2630  fprintf (stderr, "deleting measurements matching the following\n");
    2731  fprintf (stderr, "image ID range : %d to %d\n", DELETE_MIN_IMAGE_ID, DELETE_MAX_IMAGE_ID);
     32  fprintf (stderr, "det ID range : %d to %d\n", DELETE_MIN_DET_ID, DELETE_MAX_DET_ID);
     33  fprintf (stderr, "cat ID range : %d to %d\n", DELETE_MIN_CAT_ID, DELETE_MAX_CAT_ID);
    2834  fprintf (stderr, "photcode range : %d to %d\n", DELETE_MIN_PHOTCODE, DELETE_MAX_PHOTCODE);
    2935  fprintf (stderr, "time range (UNIX) : %d to %d\n", DELETE_MIN_TIME, DELETE_MAX_TIME);
     
    133139
    134140    // save backup of original cpm file
    135     if (!dvo_catalog_subset_backup (&catalog, ".dlz")) {
     141    if (!dvo_catalog_subset_backup (&catalog, BACKUP_EXTNAME)) {
    136142      fprintf (stderr, "ERROR: failed to make backup cpt table for catalog %s\n", catalog.filename);
    137143      exit (1);
    138144    }
    139     if (!dvo_catalog_subset_backup (catalog.measure_catalog, ".d1z")) {
     145    if (!dvo_catalog_subset_backup (catalog.measure_catalog, BACKUP_EXTNAME)) {
    140146      fprintf (stderr, "ERROR: failed to make backup cpm table for catalog %s\n", catalog.filename);
    141147      exit (1);
    142148    }
    143     if (!dvo_catalog_subset_backup (catalog.secfilt_catalog, ".dlz")) {
     149    if (!dvo_catalog_subset_backup (catalog.secfilt_catalog, BACKUP_EXTNAME)) {
    144150      fprintf (stderr, "ERROR: failed to make backup cps table for catalog %s\n", catalog.filename);
    145151      exit (1);
     
    214220              UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    215221
     222    if (DELETE_MIN_DET_ID) strextend (&command, "-delete-min-detID %d", DELETE_MIN_DET_ID);
     223    if (DELETE_MAX_DET_ID) strextend (&command, "-delete-max-detID %d", DELETE_MAX_DET_ID);
     224    if (DELETE_MIN_CAT_ID) strextend (&command, "-delete-min-catID %d", DELETE_MIN_CAT_ID);
     225    if (DELETE_MAX_CAT_ID) strextend (&command, "-delete-max-catID %d", DELETE_MAX_CAT_ID);
     226
    216227    if (DELETE_MIN_IMAGE_ID) strextend (&command, "-delete-min-imageID %d", DELETE_MIN_IMAGE_ID);
    217228    if (DELETE_MAX_IMAGE_ID) strextend (&command, "-delete-max-imageID %d", DELETE_MAX_IMAGE_ID);
     
    234245    if (UPDATE)          { strextend (&command, "-update");             }
    235246    if (SAVE_DELETES)    { strextend (&command, "-save-deletes");    }
     247
     248    if (BACKUP_EXTNAME)  { strextend (&command, "-backup-extname %s", BACKUP_EXTNAME);    }
    236249
    237250    fprintf (stderr, "command: %s\n", command);
     
    356369
    357370    // does this measure match our selection criteria?
     371    if (measure[i].detID > DELETE_MAX_DET_ID) continue;
     372    if (measure[i].detID < DELETE_MIN_DET_ID) continue;
     373
     374    if (measure[i].catID > DELETE_MAX_CAT_ID) continue;
     375    if (measure[i].catID < DELETE_MIN_CAT_ID) continue;
     376
    358377    if (measure[i].imageID > DELETE_MAX_IMAGE_ID) continue;
    359378    if (measure[i].imageID < DELETE_MIN_IMAGE_ID) continue;
     
    367386    measureDrop[i] = TRUE;
    368387    off_t N = measure[i].averef;
    369     if (VERBOSE) fprintf (stderr, "0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[i].imageID, measure[i].detID, average[N].R, average[N].D, measure[i].photcode);
     388    if (VERBOSE) fprintf (stderr, "0x%08x 0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[i].imageID, measure[i].detID, measure[i].catID, average[N].R, average[N].D, measure[i].photcode);
    370389    if (fsave) {
    371       fprintf (fsave, "0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[i].imageID, measure[i].detID, average[N].R, average[N].D, measure[i].photcode);
     390      fprintf (fsave, "0x%08x 0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[i].imageID, measure[i].detID, measure[i].catID, average[N].R, average[N].D, measure[i].photcode);
    372391    }
    373392    if (isGPC1chip(measure[i].photcode)) {
  • trunk/Ohana/src/dvomerge/include/dvomerge.h

    r39536 r39926  
    6161int    SKIP_MEASURE;
    6262int    SKIP_LENSING;
     63int    SKIP_LENSOBJ;
    6364int    SKIP_STARPAR;
    6465int    SKIP_GALPHOT;
     
    171172off_t     *build_measure_links    PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));
    172173off_t     *init_measure_links     PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));
    173 int        add_meas_link          PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE));
     174int        add_measure_link       PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE));
    174175Measure   *sort_measure           PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next));
    175176
    176177off_t     *build_lensing_links    PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing));
    177178off_t     *init_lensing_links     PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing));
    178 int        add_lens_link          PROTO((Average *average, off_t *next, off_t Nlensing, off_t NLENSING));
     179int        add_lensing_link       PROTO((Average *average, off_t *next, off_t Nlensing, off_t NLENSING));
    179180Lensing   *sort_lensing           PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next));
     181
     182off_t     *build_lensobj_links    PROTO((Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj));
     183off_t     *init_lensobj_links     PROTO((Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj));
     184int        add_lensobj_link       PROTO((Average *average, off_t *next, off_t Nlensobj, off_t NLENSOBJ));
     185Lensobj   *sort_lensobj           PROTO((Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj, off_t *next));
    180186
    181187off_t     *build_starpar_links    PROTO((Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar));
    182188off_t     *init_starpar_links     PROTO((Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar));
    183 int        add_star_link          PROTO((Average *average, off_t *next, off_t Nstarpar, off_t NSTARPAR));
     189int        add_starpar_link               PROTO((Average *average, off_t *next, off_t Nstarpar, off_t NSTARPAR));
    184190StarPar   *sort_starpar           PROTO((Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next));
    185191
    186192off_t     *build_galphot_links    PROTO((Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot));
    187193off_t     *init_galphot_links     PROTO((Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot));
    188 int        add_galp_link          PROTO((Average *average, off_t *next, off_t Ngalphot, off_t NGALPHOT));
     194int        add_galphot_link               PROTO((Average *average, off_t *next, off_t Ngalphot, off_t NGALPHOT));
    189195GalPhot   *sort_galphot           PROTO((Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot, off_t *next));
    190196
    191197off_t     *init_missing_links     PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing));
    192 int        add_miss_link          PROTO((Average *average, off_t *next, off_t Nmissing));
     198int        add_missing_link               PROTO((Average *average, off_t *next, off_t Nmissing));
    193199Missing   *sort_missing           PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss));
    194200
  • trunk/Ohana/src/dvomerge/src/LoadCatalog.c

    r39536 r39926  
    99
    1010  // always load all of the data (if any exists)
    11   // XXXX TEMP HACK : skip GALPHOT
    1211
    13   catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSOBJ;
     12  catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT;
    1413
    1514  if (SKIP_MEASURE) {
     
    2322  } else {
    2423    catalog[0].catflags = catalog[0].catflags | DVO_LOAD_LENSING;
     24  }
     25
     26  if (SKIP_LENSOBJ)  {
     27    catalog[0].catflags = catalog[0].catflags | DVO_SKIP_LENSOBJ;
     28  } else {
     29    catalog[0].catflags = catalog[0].catflags | DVO_LOAD_LENSOBJ;
    2530  }
    2631
  • trunk/Ohana/src/dvomerge/src/args.c

    r39536 r39926  
    5656  if ((N = get_argument (*argc, argv, "-skip-lensing"))) {
    5757    SKIP_LENSING = TRUE;
     58    remove_argument (N, argc, argv);
     59  }
     60  SKIP_LENSOBJ = FALSE;
     61  if ((N = get_argument (*argc, argv, "-skip-lensobj"))) {
     62    SKIP_LENSOBJ = TRUE;
    5863    remove_argument (N, argc, argv);
    5964  }
     
    340345    remove_argument (N, argc, argv);
    341346  }
     347  SKIP_LENSOBJ = FALSE;
     348  if ((N = get_argument (*argc, argv, "-skip-lensobj"))) {
     349    SKIP_LENSOBJ = TRUE;
     350    remove_argument (N, argc, argv);
     351  }
    342352  SKIP_STARPAR = FALSE;
    343353  if ((N = get_argument (*argc, argv, "-skip-starpar"))) {
  • trunk/Ohana/src/dvomerge/src/build_links.c

    r39536 r39926  
    1515data: they refer to the sequence number in the data blocks.
    1616
    17 next_meas is a list of the equivalent sequence of the measure block as if it were sorted.
     17next_measure is a list of the equivalent sequence of the measure block as if it were sorted.
    1818
    1919to find the sequence of measurements for a given average:
    2020n_0 = average->measureOffset
    21 n_1 = next_meas[n_0]
    22 n_i = next_meas[n_i-1]
     21n_1 = next_measure[n_0]
     22n_i = next_measure[n_i-1]
    2323
    2424*/
     
    3131
    3232  off_t i, j, N;
    33   off_t *next_meas;
     33  off_t *next_measure;
    3434
    3535  if (!measure) return NULL;
     
    3838  N = 0;
    3939
    40   ALLOCATE (next_meas, off_t, Nmeasure);
     40  ALLOCATE (next_measure, off_t, Nmeasure);
    4141  for (i = 0; i < Naverage; i++) {
    4242    if (!average[i].Nmeasure) continue;
     
    4545    for (j = 0; j < average[i].Nmeasure - 1; j++, N++) {
    4646      myAssert (measure[m+j+1].averef == i, "not sorted");
    47       next_meas[N] = N + 1;
     47      next_measure[N] = N + 1;
    4848      if (N >= Nmeasure) {
    4949        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    5050      }
    5151    }
    52     next_meas[N] = -1;
     52    next_measure[N] = -1;
    5353    if (N >= Nmeasure) {
    5454      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    6161    N++;
    6262  }
    63   return (next_meas);
     63  return (next_measure);
    6464}
    6565
     
    7474
    7575  off_t i, m, k, Nm, averef;
    76   off_t *next_meas;
    77 
    78   ALLOCATE (next_meas, off_t, Nmeasure);
     76  off_t *next_measure;
     77
     78  ALLOCATE (next_measure, off_t, Nmeasure);
    7979
    8080  /* reset the Nm, offset values for average */
     
    8787    averef = measure[Nm].averef;
    8888    m = average[averef].measureOffset; 
    89     next_meas[Nm] = -1;
     89    next_measure[Nm] = -1;
    9090
    9191    if (m == -1) { /* no links yet for source */
     
    9595    }
    9696
    97     for (k = 0; next_meas[m] != -1; k++) {
    98       m = next_meas[m];
     97    for (k = 0; next_measure[m] != -1; k++) {
     98      m = next_measure[m];
    9999      if (m >= Nmeasure) {
    100100        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    103103
    104104    average[averef].Nmeasure = k + 2;
    105     next_meas[m] = Nm;
     105    next_measure[m] = Nm;
    106106    if (m >= Nmeasure) {
    107107      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    108108    }
    109109  }
    110   return (next_meas);
     110  return (next_measure);
    111111}
    112112
    113113/* average[].measureOffset, average[].Nmeasure are valid within an addstar run */
    114 int add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) {
     114int add_measure_link (Average *average, off_t *next_measure, off_t Nmeasure, off_t NMEASURE) {
    115115
    116116  off_t k, m;
    117117
    118   /* if we have trouble, check validity of next_meas[m] : m < Nmeasure */
     118  /* if we have trouble, check validity of next_measure[m] : m < Nmeasure */
    119119  m = average[0].measureOffset; 
    120120
    121121  for (k = 0; k < average[0].Nmeasure - 1; k++)  {
    122     m = next_meas[m];
     122    m = next_measure[m];
    123123    if (m >= NMEASURE) {
    124124      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    127127
    128128  /* set up references */
    129   next_meas[Nmeasure] = -1;
     129  next_measure[Nmeasure] = -1;
    130130  if (Nmeasure >= NMEASURE) {
    131131    fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n");
     
    136136    average[0].measureOffset = Nmeasure;
    137137  } else {
    138     next_meas[m] = Nmeasure;
     138    next_measure[m] = Nmeasure;
    139139    if (m >= NMEASURE) {
    140140      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    145145}
    146146
    147 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) {
     147Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_measure) {
    148148
    149149  off_t i, k, n, np, N;
     
    169169      tmpmeasure[N].averef = i;
    170170      np = n;
    171       n = next_meas[n];
     171      n = next_measure[n];
    172172    }
    173173  }
     
    183183
    184184  off_t i, j, N;
    185   off_t *next_miss;
     185  off_t *next_missing;
    186186
    187187  N = 0;
    188188
    189   ALLOCATE (next_miss, off_t, Nmissing);
     189  ALLOCATE (next_missing, off_t, Nmissing);
    190190  for (i = 0; i < Naverage; i++) {
    191191    for (j = 0; j < average[i].Nmissing - 1; j++, N++) {
    192       next_miss[N] = N + 1;
     192      next_missing[N] = N + 1;
    193193    }
    194194    if (average[i].Nmissing > 0) {
    195       next_miss[N] = -1;
     195      next_missing[N] = -1;
    196196      if (N >= Nmissing) {
    197197        fprintf (stderr, "overflow in init_missing_links");
     
    202202
    203203  }
    204   return (next_miss);
    205 }
    206 
    207 int add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) {
     204  return (next_missing);
     205}
     206
     207int add_missing_link (Average *average, off_t *next_missing, off_t Nmissing) {
    208208
    209209  off_t k, m;
     
    212212  if (average[0].Nmissing < 1) {
    213213    average[0].missingOffset = Nmissing;
    214     next_miss[Nmissing] = -1;
     214    next_missing[Nmissing] = -1;
    215215    return (TRUE);
    216216  }
    217217
    218218  m = average[0].missingOffset; 
    219   for (k = 0; k < average[0].Nmissing - 1; k++) m = next_miss[m];
     219  for (k = 0; k < average[0].Nmissing - 1; k++) m = next_missing[m];
    220220  /* set up references */
    221   next_miss[Nmissing] = -1;
    222   next_miss[m] = Nmissing;
     221  next_missing[Nmissing] = -1;
     222  next_missing[m] = Nmissing;
    223223  return (TRUE);
    224224}
     
    227227   we must always save the missing table, if it exists */
    228228
    229 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) {
     229Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_missing) {
    230230
    231231  off_t i, k, n, N;
     
    240240    for (k = 0; k < average[i].Nmissing; k++, N++) {
    241241      tmpmissing[N] = missing[n];
    242       n = next_miss[n];
     242      n = next_missing[n];
    243243    }
    244244  }
     
    254254
    255255  off_t i, j, N;
    256   off_t *next_lens;
     256  off_t *next_lensing;
    257257
    258258  if (!lensing) return NULL;
     
    261261  N = 0;
    262262
    263   ALLOCATE (next_lens, off_t, Nlensing);
     263  ALLOCATE (next_lensing, off_t, Nlensing);
    264264  for (i = 0; i < Naverage; i++) {
    265265    if (!average[i].Nlensing) continue;
     
    268268    for (j = 0; j < average[i].Nlensing - 1; j++, N++) {
    269269      myAssert (lensing[m+j+1].averef == i, "not sorted");
    270       next_lens[N] = N + 1;
     270      next_lensing[N] = N + 1;
    271271      if (N >= Nlensing) {
    272272        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    273273      }
    274274    }
    275     next_lens[N] = -1;
     275    next_lensing[N] = -1;
    276276    if (N >= Nlensing) {
    277277      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    284284    N++;
    285285  }
    286   return (next_lens);
     286  return (next_lensing);
    287287}
    288288
     
    297297
    298298  off_t i, m, k, Nm, averef;
    299   off_t *next_lens;
    300 
    301   ALLOCATE (next_lens, off_t, Nlensing);
     299  off_t *next_lensing;
     300
     301  ALLOCATE (next_lensing, off_t, Nlensing);
    302302
    303303  /* reset the Nm, offset values for average */
     
    310310    averef = lensing[Nm].averef;
    311311    m = average[averef].lensingOffset; 
    312     next_lens[Nm] = -1;
     312    next_lensing[Nm] = -1;
    313313
    314314    if (m == -1) { /* no links yet for source */
     
    318318    }
    319319
    320     for (k = 0; next_lens[m] != -1; k++) {
    321       m = next_lens[m];
     320    for (k = 0; next_lensing[m] != -1; k++) {
     321      m = next_lensing[m];
    322322      if (m >= Nlensing) {
    323323        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    326326
    327327    average[averef].Nlensing = k + 2;
    328     next_lens[m] = Nm;
     328    next_lensing[m] = Nm;
    329329    if (m >= Nlensing) {
    330330      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    331331    }
    332332  }
    333   return (next_lens);
     333  return (next_lensing);
    334334}
    335335
    336336/* average[].lensingOffset, average[].Nlensing are valid within an addstar run */
    337 int add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) {
     337int add_lensing_link (Average *average, off_t *next_lensing, off_t Nlensing, off_t NLENSING) {
    338338
    339339  off_t k, m;
    340340
    341   /* if we have trouble, check validity of next_lens[m] : m < Nlensing */
     341  /* if we have trouble, check validity of next_lensing[m] : m < Nlensing */
    342342  m = average[0].lensingOffset; 
    343343
    344344  for (k = 0; k < average[0].Nlensing - 1; k++)  {
    345     m = next_lens[m];
     345    m = next_lensing[m];
    346346    if (m >= NLENSING) {
    347347      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    350350
    351351  /* set up references */
    352   next_lens[Nlensing] = -1;
     352  next_lensing[Nlensing] = -1;
    353353  if (Nlensing >= NLENSING) {
    354354    fprintf (stderr, "WARNING: Nlensing out of bounds (1)\n");
     
    359359    average[0].lensingOffset = Nlensing;
    360360  } else {
    361     next_lens[m] = Nlensing;
     361    next_lensing[m] = Nlensing;
    362362    if (m >= NLENSING) {
    363363      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    368368}
    369369
    370 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) {
     370Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lensing) {
    371371
    372372  off_t i, k, n, np, N;
     
    392392      tmplensing[N].averef = i;
    393393      np = n;
    394       n = next_lens[n];
     394      n = next_lensing[n];
    395395    }
    396396  }
    397397  free (lensing);
    398398  return (tmplensing);
     399}
     400
     401/*** Lensobj ****************************************************************************************/
     402
     403/* build the initial links assuming the table is sorted,
     404   not partial, and has a correct set of average[].lensobjOffset,Nlensobj values */
     405off_t *init_lensobj_links (Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj) {
     406
     407  off_t i, j, N;
     408  off_t *next_lensobj;
     409
     410  if (!lensobj) return NULL;
     411  if (SKIP_LENSOBJ) return NULL;
     412
     413  N = 0;
     414
     415  ALLOCATE (next_lensobj, off_t, Nlensobj);
     416  for (i = 0; i < Naverage; i++) {
     417    if (!average[i].Nlensobj) continue;
     418    // off_t m = average[i].lensobjOffset;
     419    // myAssert (lensobj[m].averef == i, "not sorted");
     420    for (j = 0; j < average[i].Nlensobj - 1; j++, N++) {
     421      // myAssert (lensobj[m+j+1].averef == i, "not sorted");
     422      next_lensobj[N] = N + 1;
     423      if (N >= Nlensobj) {
     424        fprintf (stderr, "WARNING: N out of bounds (1)\n");
     425      }
     426    }
     427    next_lensobj[N] = -1;
     428    if (N >= Nlensobj) {
     429      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     430    }
     431
     432    if (N >= Nlensobj) {
     433      fprintf (stderr, "overflow in init_lensobj_links\n");
     434      abort ();
     435    }
     436    N++;
     437  }
     438  return (next_lensobj);
     439}
     440
     441/* construct lensobj links which are valid FOR THIS LOAD
     442 * - if we have a full load, we will get links which can
     443 *   be used by other programs (eg, relphot, etc)
     444 * - if we have a partial load, the links are only valid
     445 *   for that partial load
     446 */
     447
     448off_t *build_lensobj_links (Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj) {
     449
     450  fprintf (stderr, "input is not sorted but contains lensobj -- trouble\n");
     451  exit (2);
     452
     453# if (0)
     454
     455  off_t i, m, k, Nm, averef;
     456  off_t *next_lensobj;
     457
     458  ALLOCATE (next_lensobj, off_t, Nlensobj);
     459
     460  /* reset the Nm, offset values for average */
     461  for (i = 0; i < Naverage; i++) {
     462    average[i].lensobjOffset = -1;
     463    average[i].Nlensobj     =  0;
     464  }
     465
     466  for (Nm = 0; Nm < Nlensobj; Nm++) {
     467    averef = lensobj[Nm].averef;
     468    m = average[averef].lensobjOffset; 
     469    next_lensobj[Nm] = -1;
     470
     471    if (m == -1) { /* no links yet for source */
     472      average[averef].lensobjOffset = Nm;
     473      average[averef].Nlensobj     = 1;
     474      continue;
     475    }
     476
     477    for (k = 0; next_lensobj[m] != -1; k++) {
     478      m = next_lensobj[m];
     479      if (m >= Nlensobj) {
     480        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     481      }
     482    }
     483
     484    average[averef].Nlensobj = k + 2;
     485    next_lensobj[m] = Nm;
     486    if (m >= Nlensobj) {
     487      fprintf (stderr, "WARNING: m out of bounds (2)\n");
     488    }
     489  }
     490  return (next_lensobj);
     491# endif
     492}
     493
     494/* average[].lensobjOffset, average[].Nlensobj are valid within an addstar run */
     495int add_lensobj_link (Average *average, off_t *next_lensobj, off_t Nlensobj, off_t NLENSOBJ) {
     496
     497  off_t k, m;
     498
     499  /* if we have trouble, check validity of next_lensobj[m] : m < Nlensobj */
     500  m = average[0].lensobjOffset; 
     501
     502  for (k = 0; k < average[0].Nlensobj - 1; k++)  {
     503    m = next_lensobj[m];
     504    if (m >= NLENSOBJ) {
     505      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     506    }
     507  }
     508
     509  /* set up references */
     510  next_lensobj[Nlensobj] = -1;
     511  if (Nlensobj >= NLENSOBJ) {
     512    fprintf (stderr, "WARNING: Nlensobj out of bounds (1)\n");
     513  }
     514
     515  // if Nlensobj is 0, m may have been mis-set; add to the end
     516  if ((average[0].Nlensobj == 0) || (m == -1)) {
     517    average[0].lensobjOffset = Nlensobj;
     518  } else {
     519    next_lensobj[m] = Nlensobj;
     520    if (m >= NLENSOBJ) {
     521      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     522    }
     523  }
     524
     525  return (TRUE);
     526}
     527
     528Lensobj *sort_lensobj (Average *average, off_t Naverage, Lensobj *lensobj, off_t Nlensobj, off_t *next_lensobj) {
     529
     530  off_t i, k, n, np, N;
     531  Lensobj *tmplensobj;
     532
     533  /* fix order of Lensobj (memory intensive, but fast) */
     534  np = -1;
     535  N = 0;
     536  ALLOCATE (tmplensobj, Lensobj, Nlensobj);
     537  for (i = 0; i < Naverage; i++) {
     538    if (!average[i].Nlensobj) continue;
     539    n = average[i].lensobjOffset;
     540    average[i].lensobjOffset = N;
     541    int myObjID = average[i].objID;
     542    for (k = 0; k < average[i].Nlensobj; k++, N++) {
     543      if (n == -1) {
     544        fprintf (stderr, "entry after %d has a problem\n", (int) np);
     545        abort();
     546      }
     547      tmplensobj[N] = lensobj[n];
     548      // myAssert (lensobj[n].averef == i, "error in averef");
     549      myAssert ((lensobj[n].objID == myObjID) || (lensobj[n].objID == -1), "error in objID?");
     550      // tmplensobj[N].averef = i;
     551      np = n;
     552      n = next_lensobj[n];
     553    }
     554  }
     555  free (lensobj);
     556  return (tmplensobj);
    399557}
    400558
     
    406564
    407565  off_t i, j, N;
    408   off_t *next_star;
     566  off_t *next_starpar;
    409567
    410568  if (!starpar) return NULL;
     
    415573  // NOTE that is we choose DVO_SKIP_STARPAR, catalog.starpar is NULL.
    416574  // this code will let merge_catalogs_old.c do nothing for starpar
    417   ALLOCATE (next_star, off_t, Nstarpar);
    418   if (!starpar) return next_star;
     575  ALLOCATE (next_starpar, off_t, Nstarpar);
     576  if (!starpar) return next_starpar;
    419577
    420578  for (i = 0; i < Naverage; i++) {
     
    424582    for (j = 0; j < average[i].Nstarpar - 1; j++, N++) {
    425583      myAssert (starpar[m+j+1].averef == i, "not sorted");
    426       next_star[N] = N + 1;
     584      next_starpar[N] = N + 1;
    427585      if (N >= Nstarpar) {
    428586        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    429587      }
    430588    }
    431     next_star[N] = -1;
     589    next_starpar[N] = -1;
    432590    if (N >= Nstarpar) {
    433591      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    440598    N++;
    441599  }
    442   return (next_star);
     600  return (next_starpar);
    443601}
    444602
     
    453611
    454612  off_t i, m, k, Nm, averef;
    455   off_t *next_star;
    456 
    457   ALLOCATE (next_star, off_t, Nstarpar);
    458   if (!starpar) return next_star;
     613  off_t *next_starpar;
     614
     615  ALLOCATE (next_starpar, off_t, Nstarpar);
     616  if (!starpar) return next_starpar;
    459617
    460618  /* reset the Nm, offset values for average */
     
    467625    averef = starpar[Nm].averef;
    468626    m = average[averef].starparOffset; 
    469     next_star[Nm] = -1;
     627    next_starpar[Nm] = -1;
    470628
    471629    if (m == -1) { /* no links yet for source */
     
    475633    }
    476634
    477     for (k = 0; next_star[m] != -1; k++) {
    478       m = next_star[m];
     635    for (k = 0; next_starpar[m] != -1; k++) {
     636      m = next_starpar[m];
    479637      if (m >= Nstarpar) {
    480638        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    483641
    484642    average[averef].Nstarpar = k + 2;
    485     next_star[m] = Nm;
     643    next_starpar[m] = Nm;
    486644    if (m >= Nstarpar) {
    487645      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    488646    }
    489647  }
    490   return (next_star);
     648  return (next_starpar);
    491649}
    492650
    493651/* average[].starparOffset, average[].Nstarpar are valid within an addstar run */
    494 int add_star_link (Average *average, off_t *next_star, off_t Nstarpar, off_t NSTARPAR) {
     652int add_starpar_link (Average *average, off_t *next_starpar, off_t Nstarpar, off_t NSTARPAR) {
    495653
    496654  off_t k, m;
    497655
    498   /* if we have trouble, check validity of next_star[m] : m < Nstarpar */
     656  /* if we have trouble, check validity of next_starpar[m] : m < Nstarpar */
    499657  m = average[0].starparOffset; 
    500658
    501659  for (k = 0; k < average[0].Nstarpar - 1; k++)  {
    502     m = next_star[m];
     660    m = next_starpar[m];
    503661    if (m >= NSTARPAR) {
    504662      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    507665
    508666  /* set up references */
    509   next_star[Nstarpar] = -1;
     667  next_starpar[Nstarpar] = -1;
    510668  if (Nstarpar >= NSTARPAR) {
    511669    fprintf (stderr, "WARNING: Nstarpar out of bounds (1)\n");
     
    516674    average[0].starparOffset = Nstarpar;
    517675  } else {
    518     next_star[m] = Nstarpar;
     676    next_starpar[m] = Nstarpar;
    519677    if (m >= NSTARPAR) {
    520678      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    525683}
    526684
    527 StarPar *sort_starpar (Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next_star) {
     685StarPar *sort_starpar (Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next_starpar) {
    528686
    529687  off_t i, k, n, np, N;
     
    552710      tmpstarpar[N].averef = i;
    553711      np = n;
    554       n = next_star[n];
     712      n = next_starpar[n];
    555713    }
    556714  }
     
    566724
    567725  off_t i, j, N;
    568   off_t *next_galp;
     726  off_t *next_galphot;
    569727
    570728  if (galphot) return NULL;
     
    573731  N = 0;
    574732
    575   ALLOCATE (next_galp, off_t, Ngalphot);
     733  ALLOCATE (next_galphot, off_t, Ngalphot);
    576734  for (i = 0; i < Naverage; i++) {
    577735    if (!average[i].Ngalphot) continue;
     
    580738    for (j = 0; j < average[i].Ngalphot - 1; j++, N++) {
    581739      myAssert (galphot[m+j+1].averef == i, "not sorted");
    582       next_galp[N] = N + 1;
     740      next_galphot[N] = N + 1;
    583741      if (N >= Ngalphot) {
    584742        fprintf (stderr, "WARNING: N out of bounds (1)\n");
    585743      }
    586744    }
    587     next_galp[N] = -1;
     745    next_galphot[N] = -1;
    588746    if (N >= Ngalphot) {
    589747      fprintf (stderr, "WARNING: N out of bounds (2)\n");
     
    596754    N++;
    597755  }
    598   return (next_galp);
     756  return (next_galphot);
    599757}
    600758
     
    609767
    610768  off_t i, m, k, Nm, averef;
    611   off_t *next_galp;
    612 
    613   ALLOCATE (next_galp, off_t, Ngalphot);
     769  off_t *next_galphot;
     770
     771  ALLOCATE (next_galphot, off_t, Ngalphot);
    614772
    615773  /* reset the Nm, offset values for average */
     
    622780    averef = galphot[Nm].averef;
    623781    m = average[averef].galphotOffset; 
    624     next_galp[Nm] = -1;
     782    next_galphot[Nm] = -1;
    625783
    626784    if (m == -1) { /* no links yet for source */
     
    630788    }
    631789
    632     for (k = 0; next_galp[m] != -1; k++) {
    633       m = next_galp[m];
     790    for (k = 0; next_galphot[m] != -1; k++) {
     791      m = next_galphot[m];
    634792      if (m >= Ngalphot) {
    635793        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     
    638796
    639797    average[averef].Ngalphot = k + 2;
    640     next_galp[m] = Nm;
     798    next_galphot[m] = Nm;
    641799    if (m >= Ngalphot) {
    642800      fprintf (stderr, "WARNING: m out of bounds (2)\n");
    643801    }
    644802  }
    645   return (next_galp);
     803  return (next_galphot);
    646804}
    647805
    648806/* average[].galphotOffset, average[].Ngalphot are valid within an addstar run */
    649 int add_galp_link (Average *average, off_t *next_galp, off_t Ngalphot, off_t NGALPHOT) {
     807int add_galphot_link (Average *average, off_t *next_galphot, off_t Ngalphot, off_t NGALPHOT) {
    650808
    651809  off_t k, m;
    652810
    653   /* if we have trouble, check validity of next_galp[m] : m < Ngalphot */
     811  /* if we have trouble, check validity of next_galphot[m] : m < Ngalphot */
    654812  m = average[0].galphotOffset; 
    655813
    656814  for (k = 0; k < average[0].Ngalphot - 1; k++)  {
    657     m = next_galp[m];
     815    m = next_galphot[m];
    658816    if (m >= NGALPHOT) {
    659817      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     
    662820
    663821  /* set up references */
    664   next_galp[Ngalphot] = -1;
     822  next_galphot[Ngalphot] = -1;
    665823  if (Ngalphot >= NGALPHOT) {
    666824    fprintf (stderr, "WARNING: Ngalphot out of bounds (1)\n");
     
    671829    average[0].galphotOffset = Ngalphot;
    672830  } else {
    673     next_galp[m] = Ngalphot;
     831    next_galphot[m] = Ngalphot;
    674832    if (m >= NGALPHOT) {
    675833      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     
    680838}
    681839
    682 GalPhot *sort_galphot (Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot, off_t *next_galp) {
     840GalPhot *sort_galphot (Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot, off_t *next_galphot) {
    683841
    684842  off_t i, k, n, np, N;
     
    704862      tmpgalphot[N].averef = i;
    705863      np = n;
    706       n = next_galp[n];
     864      n = next_galphot[n];
    707865    }
    708866  }
  • trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c

    r39536 r39926  
    336336    if (SKIP_MEASURE)               { strextend (&command, "-skip-measure"); }
    337337    if (SKIP_LENSING)               { strextend (&command, "-skip-lensing"); }
     338    if (SKIP_LENSOBJ)               { strextend (&command, "-skip-lensobj"); }
    338339    if (SKIP_GALPHOT)               { strextend (&command, "-skip-galphot"); }
    339340    if (SKIP_STARPAR)               { strextend (&command, "-skip-starpar"); }
  • trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c

    r39342 r39926  
    1414  double *X1, *Y1, *X2, *Y2;
    1515  double dX, dY, dR;
    16   off_t *N1, *N2, *next_meas, *next_lens, *next_star, *next_galp;
    17   off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS, Nstar, NSTAR, Ngalp, NGALP;
     16  off_t *N1, *N2, *next_measure, *next_lensing, *next_lensobj, *next_starpar, *next_galphot;
     17  off_t Nave, NAVE, Nmeasure, NMEASURE, Nmatch, Nlensing, NLENSING, Nlensobj, NLENSOBJ, Nstarpar, NSTARPAR, Ngalphot, NGALPHOT;
    1818  int NsecfiltIn;
    1919  int NsecfiltOut;
     
    5151  /* internal counters */
    5252  Nmatch = 0;
    53   NMEAS = Nmeas = output[0].Nmeasure;
    54   NLENS = Nlens = output[0].Nlensing;
    55   NSTAR = Nstar = output[0].Nstarpar;
    56   NGALP = Ngalp = output[0].Ngalphot;
     53  NMEASURE = Nmeasure = output[0].Nmeasure;
     54  NLENSING = Nlensing = output[0].Nlensing;
     55  NLENSOBJ = Nlensobj = output[0].Nlensobj;
     56  NSTARPAR = Nstarpar = output[0].Nstarpar;
     57  NGALPHOT = Ngalphot = output[0].Ngalphot;
    5758
    5859  // current max obj ID for this catalog
     
    116117    // this version is only valid if we have done a full catalog load, and if the catalog
    117118    // is sorted while processed
    118     next_meas = init_measure_links (output[0].average, Nave, output[0].measure, Nmeas);
    119     next_lens = init_lensing_links (output[0].average, Nave, output[0].lensing, Nlens);
    120     next_star = init_starpar_links (output[0].average, Nave, output[0].starpar, Nstar);
    121     next_galp = init_galphot_links (output[0].average, Nave, output[0].galphot, Ngalp);
     119    next_measure = init_measure_links (output[0].average, Nave, output[0].measure, Nmeasure);
     120    next_lensing = init_lensing_links (output[0].average, Nave, output[0].lensing, Nlensing);
     121    next_lensobj = init_lensobj_links (output[0].average, Nave, output[0].lensobj, Nlensobj);
     122    next_starpar = init_starpar_links (output[0].average, Nave, output[0].starpar, Nstarpar);
     123    next_galphot = init_galphot_links (output[0].average, Nave, output[0].galphot, Ngalphot);
    122124  } else {
    123     next_meas = build_measure_links (output[0].average, Nave, output[0].measure, Nmeas);
    124     next_lens = build_lensing_links (output[0].average, Nave, output[0].lensing, Nlens);
    125     next_star = build_starpar_links (output[0].average, Nave, output[0].starpar, Nstar);
    126     next_galp = build_galphot_links (output[0].average, Nave, output[0].galphot, Ngalp);
     125    next_measure = build_measure_links (output[0].average, Nave, output[0].measure, Nmeasure);
     126    next_lensing = build_lensing_links (output[0].average, Nave, output[0].lensing, Nlensing);
     127    next_lensobj = build_lensobj_links (output[0].average, Nave, output[0].lensobj, Nlensobj);
     128    next_starpar = build_starpar_links (output[0].average, Nave, output[0].starpar, Nstarpar);
     129    next_galphot = build_galphot_links (output[0].average, Nave, output[0].galphot, Ngalphot);
    127130  }   
    128131
     
    183186
    184187    /* make sure there is space for next Nmeasure entries */
    185     if (Nmeas + input[0].average[N].Nmeasure >= NMEAS) {
    186       NMEAS = Nmeas + input[0].average[N].Nmeasure + 1000;
    187       REALLOCATE (next_meas, off_t, NMEAS);
    188       REALLOCATE (output[0].measure, Measure, NMEAS);
    189     }
    190     if (Nlens + input[0].average[N].Nlensing >= NLENS) {
    191       NLENS = Nlens + input[0].average[N].Nlensing + 1000;
    192       REALLOCATE (next_lens, off_t, NLENS);
    193       REALLOCATE (output[0].lensing, Lensing, NLENS);
    194     }
    195     if (Nstar + input[0].average[N].Nstarpar >= NSTAR) {
    196       NSTAR = Nstar + input[0].average[N].Nstarpar + 1000;
    197       REALLOCATE (next_star, off_t, NSTAR);
    198       REALLOCATE (output[0].starpar, StarPar, NSTAR);
    199     }
    200     if (Ngalp + input[0].average[N].Ngalphot >= NGALP) {
    201       NGALP = Ngalp + input[0].average[N].Ngalphot + 1000;
    202       REALLOCATE (next_galp, off_t, NGALP);
    203       REALLOCATE (output[0].galphot, GalPhot, NGALP);
     188    if (Nmeasure + input[0].average[N].Nmeasure >= NMEASURE) {
     189      NMEASURE = Nmeasure + input[0].average[N].Nmeasure + 1000;
     190      REALLOCATE (next_measure, off_t, NMEASURE);
     191      REALLOCATE (output[0].measure, Measure, NMEASURE);
     192    }
     193    if (Nlensing + input[0].average[N].Nlensing >= NLENSING) {
     194      NLENSING = Nlensing + input[0].average[N].Nlensing + 1000;
     195      REALLOCATE (next_lensing, off_t, NLENSING);
     196      REALLOCATE (output[0].lensing, Lensing, NLENSING);
     197    }
     198    if (Nlensobj + input[0].average[N].Nlensobj >= NLENSOBJ) {
     199      NLENSOBJ = Nlensobj + input[0].average[N].Nlensobj + 1000;
     200      REALLOCATE (next_lensobj, off_t, NLENSOBJ);
     201      REALLOCATE (output[0].lensobj, Lensobj, NLENSOBJ);
     202    }
     203    if (Nstarpar + input[0].average[N].Nstarpar >= NSTARPAR) {
     204      NSTARPAR = Nstarpar + input[0].average[N].Nstarpar + 1000;
     205      REALLOCATE (next_starpar, off_t, NSTARPAR);
     206      REALLOCATE (output[0].starpar, StarPar, NSTARPAR);
     207    }
     208    if (Ngalphot + input[0].average[N].Ngalphot >= NGALPHOT) {
     209      NGALPHOT = Ngalphot + input[0].average[N].Ngalphot + 1000;
     210      REALLOCATE (next_galphot, off_t, NGALPHOT);
     211      REALLOCATE (output[0].galphot, GalPhot, NGALPHOT);
    204212    }
    205213
     
    212220      if (REPLACE_TYCHO) {
    213221        int Minp =  input[0].average[N].measureOffset;
    214         Nreplace = replace_tycho (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[Minp]);
     222        Nreplace = replace_tycho (&output[0].average[n], output[0].measure, next_measure, &input[0].average[N], &input[0].measure[Minp]);
    215223        if (Nreplace == 6) {
    216           output[0].found_t[n] = Nmeas;
     224          output[0].found_t[n] = Nmeasure;
    217225          i++;
    218226          continue;
     
    227235          // index to first measure for this object
    228236          // XXX this does not support lensing, starpar, or galphot measurements
    229           if (replace_match (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[offset])) {
     237          if (replace_match (&output[0].average[n], output[0].measure, next_measure, &input[0].average[N], &input[0].measure[offset])) {
    230238            continue;
    231239          }
    232240        }
    233241        /* add to end of measurement list */
    234         add_meas_link (&output[0].average[n], next_meas, Nmeas, NMEAS);
     242        add_measure_link (&output[0].average[n], next_measure, Nmeasure, NMEASURE);
    235243       
    236244        // set the new measurements
    237         output[0].measure[Nmeas] = input[0].measure[offset];
     245        output[0].measure[Nmeasure] = input[0].measure[offset];
    238246
    239247        // old code: find R,D using average_in[0], the get offset relative to average_out[0].  no longer
     
    241249        // Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0;
    242250        // Din = input[0].average[N].D - input[0].measure[offset].dD / 3600.0;
    243         // output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin);
    244         // output[0].measure[Nmeas].dD = 3600.0*(output[0].average[n].D - Din);
    245 
    246         output[0].measure[Nmeas].dbFlags  = 0;  // XXX why reset these?
    247         output[0].measure[Nmeas].averef   = n;
    248         output[0].measure[Nmeas].objID    = output[0].average[n].objID;
    249         output[0].measure[Nmeas].catID    = output[0].catID;
    250 
    251         assert (output[0].measure[Nmeas].averef < Nave);
    252 
    253         // fprintf (stderr, "Nave : "OFF_T_FMT", Nmeas : "OFF_T_FMT", dR: %f, dD: %f, catID: %d\n",  n,  Nmeas, output[0].measure[Nmeas].dR, output[0].measure[Nmeas].dD, output[0].measure[i].catID);
    254 
    255         float dRoff = dvoOffsetR(&output[0].measure[Nmeas], &output[0].average[n]);
     251        // output[0].measure[Nmeasure].dR = 3600.0*(output[0].average[n].R - Rin);
     252        // output[0].measure[Nmeasure].dD = 3600.0*(output[0].average[n].D - Din);
     253
     254        output[0].measure[Nmeasure].dbFlags  = 0;  // XXX why reset these?
     255        output[0].measure[Nmeasure].averef   = n;
     256        output[0].measure[Nmeasure].objID    = output[0].average[n].objID;
     257        output[0].measure[Nmeasure].catID    = output[0].catID;
     258
     259        assert (output[0].measure[Nmeasure].averef < Nave);
     260
     261        // fprintf (stderr, "Nave : "OFF_T_FMT", Nmeasure : "OFF_T_FMT", dR: %f, dD: %f, catID: %d\n",  n,  Nmeasure, output[0].measure[Nmeasure].dR, output[0].measure[Nmeasure].dD, output[0].measure[i].catID);
     262
     263        float dRoff = dvoOffsetR(&output[0].measure[Nmeasure], &output[0].average[n]);
    256264
    257265        // rationalize R
    258266        if (dRoff > +180.0*3600.0) {
    259267          // average on high end of boundary, move star up
    260           output[0].measure[Nmeas].R += 360.0;
     268          output[0].measure[Nmeasure].R += 360.0;
    261269          dRoff -= 360.0*3600.0;
    262270        }
    263271        if (dRoff < -180.0*3600.0) {
    264272          // average on low end of boundary, move star down
    265           output[0].measure[Nmeas].R -= 360.0;
     273          output[0].measure[Nmeasure].R -= 360.0;
    266274          dRoff += 360.0*3600.0;
    267275        }
     
    272280            fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n",
    273281                     output[0].average[n].R, output[0].average[n].D,
    274                      output[0].measure[Nmeas].R, output[0].measure[Nmeas].D,
     282                     output[0].measure[Nmeasure].R, output[0].measure[Nmeasure].D,
    275283                     X1[i], X2[Jmin], Y1[i], Y2[Jmin]);
    276284            // XXX abort on this? -- this is a bad failure...
     
    278286        }
    279287        output[0].average[n].Nmeasure ++;
    280         Nmeas ++;
     288        Nmeasure ++;
    281289      }
    282290    }
     
    286294      for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin++) {
    287295        /* add to end of lensing list */
    288         add_lens_link (&output[0].average[n], next_lens, Nlens, NLENS);
     296        add_lensing_link (&output[0].average[n], next_lensing, Nlensing, NLENSING);
    289297       
    290298        // set the new lensing
    291299        off_t lensoff = input[0].average[N].lensingOffset + Nin;
    292         output[0].lensing[Nlens] = input[0].lensing[lensoff];
    293 
    294         output[0].lensing[Nlens].averef   = n;
    295         output[0].lensing[Nlens].objID    = output[0].average[n].objID;
    296         output[0].lensing[Nlens].catID    = output[0].catID;
     300        output[0].lensing[Nlensing] = input[0].lensing[lensoff];
     301
     302        output[0].lensing[Nlensing].averef   = n;
     303        output[0].lensing[Nlensing].objID    = output[0].average[n].objID;
     304        output[0].lensing[Nlensing].catID    = output[0].catID;
    297305        output[0].average[n].Nlensing ++;
    298         Nlens ++;
     306        Nlensing ++;
     307      }
     308    }
     309
     310    // if lensobj measurements exist, add them too
     311    if (output[0].lensobj && !SKIP_LENSOBJ) {
     312      for (Nin = 0; Nin < input[0].average[N].Nlensobj; Nin++) {
     313        /* add to end of lensobj list */
     314        add_lensobj_link (&output[0].average[n], next_lensobj, Nlensobj, NLENSOBJ);
     315       
     316        // set the new lensobj
     317        off_t lensoff = input[0].average[N].lensobjOffset + Nin;
     318        output[0].lensobj[Nlensobj] = input[0].lensobj[lensoff];
     319
     320        // output[0].lensobj[Nlensobj].averef   = n;
     321        output[0].lensobj[Nlensobj].objID    = output[0].average[n].objID;
     322        output[0].lensobj[Nlensobj].catID    = output[0].catID;
     323        output[0].average[n].Nlensobj ++;
     324        Nlensobj ++;
    299325      }
    300326    }
     
    304330      for (Nin = 0; Nin < input[0].average[N].Nstarpar; Nin++) {
    305331        /* add to end of lensing list */
    306         add_star_link (&output[0].average[n], next_star, Nstar, NSTAR);
     332        add_starpar_link (&output[0].average[n], next_starpar, Nstarpar, NSTARPAR);
    307333       
    308334        // set the new starpar
    309335        off_t staroff = input[0].average[N].starparOffset + Nin;
    310         output[0].starpar[Nstar] = input[0].starpar[staroff];
    311 
    312         output[0].starpar[Nstar].averef   = n;
    313         output[0].starpar[Nstar].objID    = output[0].average[n].objID;
    314         output[0].starpar[Nstar].catID    = output[0].catID;
     336        output[0].starpar[Nstarpar] = input[0].starpar[staroff];
     337
     338        output[0].starpar[Nstarpar].averef   = n;
     339        output[0].starpar[Nstarpar].objID    = output[0].average[n].objID;
     340        output[0].starpar[Nstarpar].catID    = output[0].catID;
    315341        output[0].average[n].Nstarpar ++;
    316         Nstar ++;
     342        Nstarpar ++;
    317343      }
    318344    }
     
    322348      for (Nin = 0; Nin < input[0].average[N].Ngalphot; Nin++) {
    323349        /* add to end of galphot list */
    324         add_galp_link (&output[0].average[n], next_galp, Ngalp, NGALP);
     350        add_galphot_link (&output[0].average[n], next_galphot, Ngalphot, NGALPHOT);
    325351       
    326352        // set the new galphot
    327353        off_t galpoff = input[0].average[N].galphotOffset + Nin;
    328         output[0].galphot[Ngalp] = input[0].galphot[galpoff];
    329 
    330         output[0].galphot[Ngalp].averef   = n;
    331         output[0].galphot[Ngalp].objID    = output[0].average[n].objID;
    332         output[0].galphot[Ngalp].catID    = output[0].catID;
     354        output[0].galphot[Ngalphot] = input[0].galphot[galpoff];
     355
     356        output[0].galphot[Ngalphot].averef   = n;
     357        output[0].galphot[Ngalphot].objID    = output[0].average[n].objID;
     358        output[0].galphot[Ngalphot].catID    = output[0].catID;
    333359        output[0].average[n].Ngalphot ++;
    334         Ngalp ++;
     360        Ngalphot ++;
    335361      }
    336362    }
     
    373399    /* Nm is updated, but not written out in -update mode (for existing entries)
    374400       Nm is recalculated in build_meas_links if loaded table is not sorted */
    375     output[0].found_t[n] = Nmeas;
     401    output[0].found_t[n] = Nmeasure;
    376402    i++;
    377403  }
    378   // MARKTIME("find matched stars: %f sec for "OFF_T_FMT","OFF_T_FMT" stars ("OFF_T_FMT" meas)\n", dtime, Nstars, Nave, Nmeas);
     404  // MARKTIME("find matched stars: %f sec for "OFF_T_FMT","OFF_T_FMT" stars ("OFF_T_FMT" meas)\n", dtime, Nstars, Nave, Nmeasure);
    379405
    380406  /** incorporate unmatched image stars, if this star is in field of this catalog **/
     
    384410
    385411    /* make sure there is space for next entry */
    386     if (Nmeas + input[0].average[N].Nmeasure >= NMEAS) {
    387       NMEAS = Nmeas + input[0].average[N].Nmeasure + 1000;
    388       REALLOCATE (next_meas, off_t, NMEAS);
    389       REALLOCATE (output[0].measure, Measure, NMEAS);
    390     }
    391     if (Nlens + input[0].average[N].Nlensing >= NLENS) {
    392       NLENS = Nlens + input[0].average[N].Nlensing + 1000;
    393       REALLOCATE (next_lens, off_t, NLENS);
    394       REALLOCATE (output[0].lensing, Lensing, NLENS);
    395     }
    396     if (Nstar + input[0].average[N].Nstarpar >= NSTAR) {
    397       NSTAR = Nstar + input[0].average[N].Nstarpar + 1000;
    398       REALLOCATE (next_star, off_t, NSTAR);
    399       REALLOCATE (output[0].starpar, StarPar, NSTAR);
    400     }
    401     if (Ngalp + input[0].average[N].Ngalphot >= NGALP) {
    402       NGALP = Ngalp + input[0].average[N].Ngalphot + 1000;
    403       REALLOCATE (next_galp, off_t, NGALP);
    404       REALLOCATE (output[0].galphot, GalPhot, NGALP);
     412    if (Nmeasure + input[0].average[N].Nmeasure >= NMEASURE) {
     413      NMEASURE = Nmeasure + input[0].average[N].Nmeasure + 1000;
     414      REALLOCATE (next_measure, off_t, NMEASURE);
     415      REALLOCATE (output[0].measure, Measure, NMEASURE);
     416    }
     417    if (Nlensing + input[0].average[N].Nlensing >= NLENSING) {
     418      NLENSING = Nlensing + input[0].average[N].Nlensing + 1000;
     419      REALLOCATE (next_lensing, off_t, NLENSING);
     420      REALLOCATE (output[0].lensing, Lensing, NLENSING);
     421    }
     422    if (Nlensobj + input[0].average[N].Nlensobj >= NLENSOBJ) {
     423      NLENSOBJ = Nlensobj + input[0].average[N].Nlensobj + 1000;
     424      REALLOCATE (next_lensobj, off_t, NLENSOBJ);
     425      REALLOCATE (output[0].lensobj, Lensobj, NLENSOBJ);
     426    }
     427    if (Nstarpar + input[0].average[N].Nstarpar >= NSTARPAR) {
     428      NSTARPAR = Nstarpar + input[0].average[N].Nstarpar + 1000;
     429      REALLOCATE (next_starpar, off_t, NSTARPAR);
     430      REALLOCATE (output[0].starpar, StarPar, NSTARPAR);
     431    }
     432    if (Ngalphot + input[0].average[N].Ngalphot >= NGALPHOT) {
     433      NGALPHOT = Ngalphot + input[0].average[N].Ngalphot + 1000;
     434      REALLOCATE (next_galphot, off_t, NGALPHOT);
     435      REALLOCATE (output[0].galphot, GalPhot, NGALPHOT);
    405436    }
    406437    if (Nave >= NAVE) {
     
    465496    /** add measurements for this input average object **/
    466497    if (output[0].measure && !SKIP_MEASURE && input[0].average[N].Nmeasure) {
    467       output[0].average[Nave].measureOffset  = Nmeas;
     498      output[0].average[Nave].measureOffset  = Nmeasure;
    468499      for (Nin = 0; Nin < input[0].average[N].Nmeasure; Nin ++) {
    469500        offset = input[0].average[N].measureOffset + Nin;
    470501       
    471502        // supply the measurments from this detection
    472         output[0].measure[Nmeas]           = input[0].measure[offset];
     503        output[0].measure[Nmeasure]           = input[0].measure[offset];
    473504       
    474505        // the following measure elements cannot be set until here:
    475         output[0].measure[Nmeas].dbFlags  = 0;
    476         output[0].measure[Nmeas].averef   = Nave;
    477         output[0].measure[Nmeas].objID    = output[0].average[Nave].objID;
    478         output[0].measure[Nmeas].catID    = output[0].catID;
     506        output[0].measure[Nmeasure].dbFlags  = 0;
     507        output[0].measure[Nmeasure].averef   = Nave;
     508        output[0].measure[Nmeasure].objID    = output[0].average[Nave].objID;
     509        output[0].measure[Nmeasure].catID    = output[0].catID;
    479510       
    480511        // as we add measurements, update Nmeasure to match
    481512        output[0].average[Nave].Nmeasure ++;
    482513
    483         /* we set next[Nmeas] to -1 here, and update correctly below */
    484         next_meas[Nmeas] = -1;
    485         Nmeas ++;
     514        /* we set next[Nmeasure] to -1 here, and update correctly below */
     515        next_measure[Nmeasure] = -1;
     516        Nmeasure ++;
    486517      }
    487518      int Ngroup = input[0].average[N].Nmeasure;
    488519      for (j = 0; j < Ngroup - 1; j++) {
    489         next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1;
     520        next_measure[Nmeasure - Ngroup + j] = Nmeasure - Ngroup + j + 1;
    490521      }
    491522    }
     
    493524    /** add lensing for this input average object **/
    494525    if (output[0].lensing && !SKIP_LENSING && input[0].average[N].Nlensing) {
    495       output[0].average[Nave].lensingOffset  = Nlens;
     526      output[0].average[Nave].lensingOffset  = Nlensing;
    496527      for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin ++) {
    497528        // supply the lensing values from this detection
    498529        off_t lensoff = input[0].average[N].lensingOffset + Nin;
    499         output[0].lensing[Nlens]           = input[0].lensing[lensoff];
     530        output[0].lensing[Nlensing]           = input[0].lensing[lensoff];
    500531
    501532        // the following lensing elements cannot be set until here:
    502         output[0].lensing[Nlens].averef   = Nave;
    503         output[0].lensing[Nlens].objID    = output[0].average[Nave].objID;
    504         output[0].lensing[Nlens].catID    = output[0].catID;
     533        output[0].lensing[Nlensing].averef   = Nave;
     534        output[0].lensing[Nlensing].objID    = output[0].average[Nave].objID;
     535        output[0].lensing[Nlensing].catID    = output[0].catID;
    505536
    506537        // as we add lensing, update Nlensing to match
    507538        output[0].average[Nave].Nlensing ++;
    508539
    509         /* we set next[Nlens] to -1 here, and update correctly below */
    510         next_lens[Nlens] = -1;
    511         Nlens ++;
     540        /* we set next[Nlensing] to -1 here, and update correctly below */
     541        next_lensing[Nlensing] = -1;
     542        Nlensing ++;
    512543      }
    513544      int Ngroup = input[0].average[N].Nlensing;
    514545      for (j = 0; j < Ngroup - 1; j++) {
    515         next_lens[Nlens - Ngroup + j] = Nlens - Ngroup + j + 1;
     546        next_lensing[Nlensing - Ngroup + j] = Nlensing - Ngroup + j + 1;
     547      }
     548    }
     549
     550    /** add lensobj for this input average object **/
     551    if (output[0].lensobj && !SKIP_LENSOBJ && input[0].average[N].Nlensobj) {
     552      output[0].average[Nave].lensobjOffset  = Nlensobj;
     553      for (Nin = 0; Nin < input[0].average[N].Nlensobj; Nin ++) {
     554        // supply the lensobj values from this detection
     555        off_t lensoff = input[0].average[N].lensobjOffset + Nin;
     556        output[0].lensobj[Nlensobj]           = input[0].lensobj[lensoff];
     557
     558        // the following lensobj elements cannot be set until here:
     559        // output[0].lensobj[Nlensobj].averef   = Nave;
     560        output[0].lensobj[Nlensobj].objID    = output[0].average[Nave].objID;
     561        output[0].lensobj[Nlensobj].catID    = output[0].catID;
     562
     563        // as we add lensobj, update Nlensobj to match
     564        output[0].average[Nave].Nlensobj ++;
     565
     566        /* we set next[Nlensobj] to -1 here, and update correctly below */
     567        next_lensobj[Nlensobj] = -1;
     568        Nlensobj ++;
     569      }
     570      int Ngroup = input[0].average[N].Nlensobj;
     571      for (j = 0; j < Ngroup - 1; j++) {
     572        next_lensobj[Nlensobj - Ngroup + j] = Nlensobj - Ngroup + j + 1;
    516573      }
    517574    }
     
    519576    /** add starpar for this input average object **/
    520577    if (output[0].starpar && !SKIP_STARPAR && input[0].average[N].Nstarpar) {
    521       output[0].average[Nave].starparOffset  = Nstar;
     578      output[0].average[Nave].starparOffset  = Nstarpar;
    522579      for (Nin = 0; Nin < input[0].average[N].Nstarpar; Nin ++) {
    523580        // supply the starpar values from this detection
    524581        off_t staroff = input[0].average[N].starparOffset + Nin;
    525         output[0].starpar[Nstar]           = input[0].starpar[staroff];
     582        output[0].starpar[Nstarpar]           = input[0].starpar[staroff];
    526583
    527584        // the following starpar elements cannot be set until here:
    528         output[0].starpar[Nstar].averef   = Nave;
    529         output[0].starpar[Nstar].objID    = output[0].average[Nave].objID;
    530         output[0].starpar[Nstar].catID    = output[0].catID;
     585        output[0].starpar[Nstarpar].averef   = Nave;
     586        output[0].starpar[Nstarpar].objID    = output[0].average[Nave].objID;
     587        output[0].starpar[Nstarpar].catID    = output[0].catID;
    531588
    532589        // as we add starpar, update Nstarpar to match
    533590        output[0].average[Nave].Nstarpar ++;
    534591
    535         /* we set next[Nstar] to -1 here, and update correctly below */
    536         next_star[Nstar] = -1;
    537         Nstar ++;
     592        /* we set next[Nstarpar] to -1 here, and update correctly below */
     593        next_starpar[Nstarpar] = -1;
     594        Nstarpar ++;
    538595      }
    539596      int Ngroup = input[0].average[N].Nstarpar;
    540597      for (j = 0; j < Ngroup - 1; j++) {
    541         next_star[Nstar - Ngroup + j] = Nstar - Ngroup + j + 1;
     598        next_starpar[Nstarpar - Ngroup + j] = Nstarpar - Ngroup + j + 1;
    542599      }
    543600    }
     
    545602    /** add galphot for this input average object **/
    546603    if (output[0].galphot && !SKIP_GALPHOT && input[0].average[N].Ngalphot) {
    547       output[0].average[Nave].galphotOffset  = Ngalp;
     604      output[0].average[Nave].galphotOffset  = Ngalphot;
    548605      for (Nin = 0; Nin < input[0].average[N].Ngalphot; Nin ++) {
    549606        // supply the galphot values from this detection
    550607        off_t galpoff = input[0].average[N].galphotOffset + Nin;
    551         output[0].galphot[Ngalp]           = input[0].galphot[galpoff];
     608        output[0].galphot[Ngalphot]           = input[0].galphot[galpoff];
    552609
    553610        // the following galphot elements cannot be set until here:
    554         output[0].galphot[Ngalp].averef   = Nave;
    555         output[0].galphot[Ngalp].objID    = output[0].average[Nave].objID;
    556         output[0].galphot[Ngalp].catID    = output[0].catID;
     611        output[0].galphot[Ngalphot].averef   = Nave;
     612        output[0].galphot[Ngalphot].objID    = output[0].average[Nave].objID;
     613        output[0].galphot[Ngalphot].catID    = output[0].catID;
    557614
    558615        // as we add galphot, update Ngalphot to match
    559616        output[0].average[Nave].Ngalphot ++;
    560617
    561         /* we set next[Ngalp] to -1 here, and update correctly below */
    562         next_galp[Ngalp] = -1;
    563         Ngalp ++;
     618        /* we set next[Ngalphot] to -1 here, and update correctly below */
     619        next_galphot[Ngalphot] = -1;
     620        Ngalphot ++;
    564621      }
    565622      int Ngroup = input[0].average[N].Ngalphot;
    566623      for (j = 0; j < Ngroup - 1; j++) {
    567         next_galp[Ngalp - Ngroup + j] = Ngalp - Ngroup + j + 1;
     624        next_galphot[Ngalphot - Ngroup + j] = Ngalphot - Ngroup + j + 1;
    568625      }
    569626    }
     
    575632
    576633  REALLOCATE (output[0].average, Average, Nave);
    577   if (!SKIP_MEASURE) { REALLOCATE (output[0].measure, Measure, Nmeas); }
    578   if (!SKIP_LENSING) { REALLOCATE (output[0].lensing, Lensing, Nlens); }
    579   if (!SKIP_STARPAR) { REALLOCATE (output[0].starpar, StarPar, Nstar); }
    580   if (!SKIP_GALPHOT) { REALLOCATE (output[0].galphot, GalPhot, Ngalp); }
     634  if (!SKIP_MEASURE) { REALLOCATE (output[0].measure, Measure, Nmeasure); }
     635  if (!SKIP_LENSING) { REALLOCATE (output[0].lensing, Lensing, Nlensing); }
     636  if (!SKIP_LENSOBJ) { REALLOCATE (output[0].lensobj, Lensobj, Nlensobj); }
     637  if (!SKIP_STARPAR) { REALLOCATE (output[0].starpar, StarPar, Nstarpar); }
     638  if (!SKIP_GALPHOT) { REALLOCATE (output[0].galphot, GalPhot, Ngalphot); }
    581639 
    582640# define NOSORT 0
     
    585643  } else {
    586644    output[0].sorted = TRUE;
    587     if (!SKIP_MEASURE) { output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeas, next_meas); }
    588     if (!SKIP_LENSING) { output[0].lensing = sort_lensing (output[0].average, Nave, output[0].lensing, Nlens, next_lens); }
    589     if (!SKIP_STARPAR) { output[0].starpar = sort_starpar (output[0].average, Nave, output[0].starpar, Nstar, next_star); }
    590     if (!SKIP_GALPHOT) { output[0].galphot = sort_galphot (output[0].average, Nave, output[0].galphot, Ngalp, next_galp); }
     645    if (!SKIP_MEASURE) { output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeasure, next_measure); }
     646    if (!SKIP_LENSING) { output[0].lensing = sort_lensing (output[0].average, Nave, output[0].lensing, Nlensing, next_lensing); }
     647    if (!SKIP_LENSOBJ) { output[0].lensobj = sort_lensobj (output[0].average, Nave, output[0].lensobj, Nlensobj, next_lensobj); }
     648    if (!SKIP_STARPAR) { output[0].starpar = sort_starpar (output[0].average, Nave, output[0].starpar, Nstarpar, next_starpar); }
     649    if (!SKIP_GALPHOT) { output[0].galphot = sort_galphot (output[0].average, Nave, output[0].galphot, Ngalphot, next_galphot); }
    591650  }
    592651
     
    594653  output[0].objID    = objID; // new max value, save on catalog close
    595654  output[0].Naverage = Nave;
    596   if (!SKIP_MEASURE) { output[0].Nmeasure = Nmeas; }
    597   if (!SKIP_LENSING) { output[0].Nlensing = Nlens; }
    598   if (!SKIP_STARPAR) { output[0].Nstarpar = Nstar; }
    599   if (!SKIP_GALPHOT) { output[0].Ngalphot = Ngalp; }
     655  if (!SKIP_MEASURE) { output[0].Nmeasure = Nmeasure; }
     656  if (!SKIP_LENSING) { output[0].Nlensing = Nlensing; }
     657  if (!SKIP_LENSOBJ) { output[0].Nlensobj = Nlensobj; }
     658  if (!SKIP_STARPAR) { output[0].Nstarpar = Nstarpar; }
     659  if (!SKIP_GALPHOT) { output[0].Ngalphot = Ngalphot; }
    600660  output[0].Nsecfilt_mem = Nave*NsecfiltOut;
    601   if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens, Ngalp: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n",  Nstars,  Nave,  Nmeas,  Nlens, Ngalp, Nmatch);
    602 
    603   free (next_meas);
    604   free (next_lens);
    605   free (next_star);
    606   free (next_galp);
     661  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeasure, Nlensing, Ngalphot: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n",  Nstars,  Nave,  Nmeasure,  Nlensing, Ngalphot, Nmatch);
     662
     663  free (next_measure);
     664  free (next_lensing);
     665  free (next_lensobj);
     666  free (next_starpar);
     667  free (next_galphot);
    607668
    608669  free (X2);
     
    625686   images have boundaries which are lines in pixels coords, but curve in RA and DEC
    626687   
    627    output[0].found_t[Ncat] but stars[Nstar].found
     688   output[0].found_t[Ncat] but stars[Nstars].found
    628689   
    629690*/
  • trunk/Ohana/src/fakeastro/Makefile

    r39242 r39926  
    5353$(SRC)/match_fake_stars.$(ARCH).o \
    5454$(SRC)/fakeastro_2mass.$(ARCH).o \
     55$(SRC)/fakeastro_gaia.$(ARCH).o \
    5556$(SRC)/make_2mass_measures.$(ARCH).o \
     57$(SRC)/make_gaia_measures.$(ARCH).o \
    5658$(SRC)/remote_hosts.$(ARCH).o
    5759
  • trunk/Ohana/src/fakeastro/include/fakeastro.h

    r38986 r39926  
    88# define RESETTIME { gettimeofday (&startTimer, (void *) NULL); }
    99
    10 typedef enum {OP_NONE, OP_GALAXY, OP_IMAGES, OP_2MASS} FakeastroOp;
     10typedef enum {OP_NONE, OP_GALAXY, OP_IMAGES, OP_2MASS, OP_GAIA} FakeastroOp;
    1111
    1212typedef struct {
     
    8787int    VERBOSE;
    8888int    VERBOSE2;
    89 int    TESTING;
    9089int    ONE_BIG_CHIP;
     90
     91float  TEST_SCALE;
     92char  *GALAXY_MODEL;
    9193
    9294int    FORCE;
     
    101103char   FAKEASTRO_REF_EPOCH[80];
    102104char   FAKEASTRO_2MASS_EPOCH[80];
     105char   FAKEASTRO_GAIA_EPOCH[80];
    103106
    104107float  RADIUS;
    105108float  MAX_MAG_2MASS;
     109float  MAX_MAG_GAIA;
    106110
    107111SkyRegion UserPatch;
     
    198202int fakeastro_2mass ();
    199203int make_2mass_measures (Catalog *catalog);
     204
     205int fakeastro_gaia ();
     206int make_gaia_measures (Catalog *catalog);
  • trunk/Ohana/src/fakeastro/src/ConfigInit.c

    r37807 r39926  
    1919  // if (!ScanConfig (config, "ADDSTAR_RADIUS",         "%lf", 0, &ADDSTAR_RADIUS))   ADDSTAR_RADIUS = 1.0;
    2020
    21   if ((FAKEASTRO_OP == OP_GALAXY) || (FAKEASTRO_OP == OP_2MASS)) {
     21  if ((FAKEASTRO_OP == OP_GALAXY) || (FAKEASTRO_OP == OP_2MASS) || (FAKEASTRO_OP == OP_GAIA)) {
    2222    // force CATDIR to be absolute (so parallel mode will work)
    2323    GetConfig (config, "CATDIR",                 "%s",  0, CATDIR);
     
    6060    strcpy (FAKEASTRO_2MASS_EPOCH, "2000/01/01,00:00:00"); // epoch of 2MASS astrometry
    6161  }
     62  if (!ScanConfig (config, "FAKEASTRO_GAIA_EPOCH", "%s", 0, FAKEASTRO_GAIA_EPOCH)) {
     63    strcpy (FAKEASTRO_GAIA_EPOCH, "2015/01/01,00:00:00"); // epoch of GAIA astrometry
     64  }
    6265
    6366  /* set the default search radius */
     
    7679
    7780  // OP_2MASS is adding detections to an existing db, the others require and empty db
    78   if (FAKEASTRO_OP != OP_2MASS) {
     81  if ((FAKEASTRO_OP != OP_2MASS) && (FAKEASTRO_OP != OP_GAIA)) {
    7982    // check for existence of CATDIR
    8083    struct stat filestat;
  • trunk/Ohana/src/fakeastro/src/args.c

    r38986 r39926  
    2626  }
    2727
    28   TESTING = FALSE;
     28  if ((N = get_argument (*argc, argv, "-gaia"))) {
     29    remove_argument (N, argc, argv);
     30    FAKEASTRO_OP = OP_GAIA;
     31  }
     32
     33  GALAXY_MODEL = NULL;
     34  if ((N = get_argument (*argc, argv, "-galaxy-model"))) {
     35    remove_argument (N, argc, argv);
     36    GALAXY_MODEL = strcreate(argv[N]);
     37    remove_argument (N, argc, argv);
     38  }
     39  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("ROESER");
     40
     41  TEST_SCALE = 1.0;
    2942  if ((N = get_argument (*argc, argv, "-testing"))) {
    3043    remove_argument (N, argc, argv);
    31     TESTING = TRUE;
     44    TEST_SCALE = atof(argv[N]);
     45    remove_argument (N, argc, argv);
    3246  }
    3347  ONE_BIG_CHIP = FALSE;
     
    114128  }
    115129
     130  MAX_MAG_GAIA = 21.0;
     131  if ((N = get_argument (*argc, argv, "-gaia-limit"))) {
     132    remove_argument (N, argc, argv);
     133    MAX_MAG_GAIA = atof(argv[N]);
     134    remove_argument (N, argc, argv);
     135  }
     136
    116137  FORCE = FALSE;
    117138  if ((N = get_argument (*argc, argv, "-force"))) {
     
    250271  // }
    251272
     273  GALAXY_MODEL = NULL;
     274  if ((N = get_argument (*argc, argv, "-galaxy-model"))) {
     275    remove_argument (N, argc, argv);
     276    GALAXY_MODEL = strcreate(argv[N]);
     277    remove_argument (N, argc, argv);
     278  }
     279  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("FEAST-HIPPARCOS");
     280
    252281  VERBOSE = VERBOSE2 = FALSE;
    253282  if ((N = get_argument (*argc, argv, "-v"))) {
     
    273302  fprintf (stderr, " additional options: \n");
    274303  fprintf (stderr, "  -region RA RA DEC DEC\n");
    275   fprintf (stderr, "  -catalog (ra) (dec)\n\n");
     304  fprintf (stderr, "  -catalog (ra) (dec)\n");
     305  fprintf (stderr, "  -testing (scale)\n\n");
    276306  fprintf (stderr, "  -v\n");
    277307  fprintf (stderr, "  -vv\n");
  • trunk/Ohana/src/fakeastro/src/fakeastro.c

    r39248 r39926  
    4141      exit (0);
    4242
     43    case OP_GAIA:
     44      fakeastro_gaia ();
     45      /* make_gaia_measures()
     46       */
     47      exit (0);
     48
    4349    default:
    4450      fprintf (stderr, "impossible!\n");
  • trunk/Ohana/src/fakeastro/src/initialize.c

    r37807 r39926  
    1717
    1818  // XXX add to config?
    19   if (!InitGalaxyModel ("ROESER")) {
    20     fprintf (stderr, "failed to init galaxy model\n");
     19  if (!InitGalaxyModel (GALAXY_MODEL)) {
     20    fprintf (stderr, "failed to init galaxy model %s\n", GALAXY_MODEL);
    2121    exit (2);
    2222  }
     
    3030
    3131  // XXX add to config?
    32   if (!InitGalaxyModel ("ROESER")) {
    33     fprintf (stderr, "failed to init galaxy model\n");
     32  if (!InitGalaxyModel (GALAXY_MODEL)) {
     33    fprintf (stderr, "failed to init galaxy model %s\n", GALAXY_MODEL);
    3434    exit (2);
    3535  }
  • trunk/Ohana/src/fakeastro/src/make_fake_stars_catalog.c

    r39248 r39926  
    116116    double dDsee = ohana_gaussdev_rnd (0.0, 1.0 / SN);
    117117
     118    // XXX TEST
     119    // dDsee = dRsee = 0.0;
     120
    118121    double dRoff = (dRpm + dRsee) / 3600.0;
    119122    double dDoff = (dDpm + dDsee) / 3600.0;
  • trunk/Ohana/src/fakeastro/src/make_fakestars.c

    r39589 r39926  
    3535      // we can generate a distribution which is uniform on the sky, in which case
    3636      // we can limit to the selected patch analyically
     37
     38      // note: r & z are generated in parsec
    3739      r = pow(drand48(), 0.33333) * FAKEASTRO_RGAL;
    3840      z = 0.0;
     
    4850      int inPatch = FALSE;
    4951      while (!inPatch) {
     52        // note: r & z are generated in parsec
    5053        z = ohana_gaussdev_rnd (0.0, FAKEASTRO_ZGAL);
    5154        r = sqrt(drand48()) * FAKEASTRO_RGAL;
     
    6871    // double y = r*sin(L);
    6972
     73    // distance here is in parsec
    7074    double distance = sqrt (SQ(r) + SQ(z));
    7175
     
    7478
    7579    double uL_sol, uB_sol;
    76     SolarMotionModel_radians(&uL_sol, &uB_sol, Lrad, Brad, distance);
     80    SolarMotionModel_radians(&uL_sol, &uB_sol, Lrad, Brad, distance / 1000.0);
     81    // note: SolarMotionModel wants distance in kpc
    7782
    7883    double uL = uL_gal + uL_sol;
     
    8085   
    8186    // XXX: amplify motion to make tests easier:
    82     if (TESTING) {
    83       uL *= 100.0;
    84       uB *= 100.0;
    85     }
     87    uL *= TEST_SCALE;
     88    uB *= TEST_SCALE;
    8689   
    8790    double uR, uD;
  • trunk/Ohana/src/kapa2/include/prototypes.h

    r39457 r39926  
    3232void          DrawLabelsRaw       PROTO((Graphic *graphic, KapaGraphWidget *graph, int color));
    3333void          DrawTextlines       PROTO((KapaGraphWidget *graph));
    34 void          DrawConnect         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    35 void          DrawHistogram       PROTO((KapaGraphWidget *graph, Gobjects *objects));
    36 int           DrawObjectN         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    37 void          DrawPoints          PROTO((KapaGraphWidget *graph, Gobjects *objects));
    38 void          ClipLine            PROTO((double x0, double y0, double x1, double y1, double X0, double Y0, double X1, double Y1));
    39 void          DrawXErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    40 void          DrawYErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
     34void          DrawConnect         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     35void          DrawHistogram       PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     36int           DrawObjectN         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     37void          DrawPoints          PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     38void          ClipLine            PROTO((Graphic *graphic, double x0, double y0, double x1, double y1, double X0, double Y0, double X1, double Y1));
     39void          DrawXErrors         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     40void          DrawYErrors         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
    4141void          DrawTick            PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis));
    4242void          AxisTickScale       PROTO((Axis *axis, double *range, double *major, double *minor, int *nsignif));
     
    115115void          PSLabels            PROTO((KapaGraphWidget *graph, FILE *f));
    116116void          PSTextlines         PROTO((KapaGraphWidget *graph, FILE *f));
     117int           PSObjectsN          PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f));
    117118void          PSConnect           PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f));
    118119void          PSHistogram         PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f));
     
    135136void          bDrawLabels         PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph));
    136137void          bDrawTextlines      PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph));
     138int           bDrawObjectsN       PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
    137139void          bDrawConnect        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
    138140void          bDrawHistogram      PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
  • trunk/Ohana/src/kapa2/src/DrawFrame.c

    r39594 r39926  
    1212
    1313  graphic = GetGraphic();
     14
     15  P = 0.5 * (1 + 0.25*graph[0].axis[0].lweight) * (hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy) + hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy));
    1416
    1517  /* each axis is drawn independently, but ticks and labels are placed according to perpendicular distance. */
     
    3032    dfy = graph[0].axis[i].dfy + 2*dy;
    3133
    32     P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    33     P *= (1 + 0.25*lweight);
     34    // P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
     35    // P *= (1 + 0.25*lweight);
    3436
    3537    XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CapNotLast, JoinMiter);
  • trunk/Ohana/src/kapa2/src/DrawObjects.c

    r39594 r39926  
    88# define FillCircle(X,Y,R) (XFillArc (graphic->display, graphic->window, graphic->gc, (int)(X-R), (int)(Y-R), abs(2*R+1), abs(2*R+1), 0, 23040))
    99
    10 # define CONNECT 0
    11 # define HISTOGRAM 1
    12 # define POINTS 2
    13 
    1410# define XCENTER 0.0
    1511# define YCENTER 0.0
     
    1713# define JOINSTYLE JoinMiter
    1814
    19 static Graphic *graphic;
     15// XXX this is not thread safe, but that is OK
     16// static Graphic *graphic;
    2017
    2118/* draw all objects for this Graph */
     
    2421  int i;
    2522 
     23  // the functions below use this global value
     24  Graphic *graphic = GetGraphic();
     25 
     26  // this function calls all of the supporting Draw... functions below
    2627  for (i = 0; i < graph[0].Nobjects; i++) {
    2728    if (DEBUG) fprintf (stderr, "object: %d\n", i);
    2829    if (DEBUG) fprintf (stderr, "Npts: %d\n", graph[0].objects[i].Npts);
    29     DrawObjectN (graph, &graph[0].objects[i]);
     30    DrawObjectN (graphic, graph, &graph[0].objects[i]);
    3031  }   
     32  XSetLineAttributes (graphic->display, graphic->gc, 0, LineSolid, CAPSTYLE, JOINSTYLE);
     33  XSetForeground (graphic->display, graphic->gc, graphic->fore);
    3134  return (TRUE);
    3235}
    3336
    3437/* Draw a specific object in the graph */
    35 int DrawObjectN (KapaGraphWidget *graph, Gobjects *object) {
     38int DrawObjectN (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    3639 
    3740  static char dot[2] = {2,3};
     
    4144  int lweight;
    4245 
    43   // this function calls all of the supporting Draw... functions below
    44   graphic = GetGraphic();
    45  
    4646  lweight = MAX (1, MIN (10, object[0].lweight));
    4747
     
    5858  /* set line type */
    5959  switch (object[0].ltype) {
    60     case 0:
    61       XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CAPSTYLE, JOINSTYLE);
    62       break;
    63     case 1:
     60    case KAPA_LINE_DOT:
    6461      XSetDashes (graphic->display, graphic->gc, 1, dot, 2);
    65       XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
    66       break;
    67     case 2:
     62      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineDoubleDash, CAPSTYLE, JOINSTYLE);
     63      break;
     64    case KAPA_LINE_DASH_SHORT:
    6865      XSetDashes (graphic->display, graphic->gc, 1, short_dash, 2);
    69       XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
    70       break;
    71     case 3:
     66      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineDoubleDash, CAPSTYLE, JOINSTYLE);
     67      break;
     68    case KAPA_LINE_DASH_LONG:
    7269      XSetDashes (graphic->display, graphic->gc, 1, long_dash, 2);
    73       XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
    74       break;
    75     case 4:
     70      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineDoubleDash, CAPSTYLE, JOINSTYLE);
     71      break;
     72    case KAPA_LINE_DOT_DASH:
    7673      XSetDashes (graphic->display, graphic->gc, 1, dot_dash, 4);
    77       XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
    78       break;
     74      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineDoubleDash, CAPSTYLE, JOINSTYLE);
     75      break;
     76    case KAPA_LINE_SOLID:
    7977    default:
    8078      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CAPSTYLE, JOINSTYLE);
     
    8886
    8987  switch (object[0].style) {
    90     case CONNECT:
    91       DrawConnect (graph, object);
    92       break;
    93     case HISTOGRAM:
    94       DrawHistogram (graph, object);
    95       break;
    96     case POINTS:
    97       DrawPoints (graph, object);
     88    case KAPA_PLOT_CONNECT:
     89      DrawConnect (graphic, graph, object);
     90      break;
     91    case KAPA_PLOT_HISTOGRAM:
     92      DrawHistogram (graphic, graph, object);
     93      break;
     94    case KAPA_PLOT_POINTS:
     95    default:
     96      DrawPoints (graphic, graph, object);
    9897      break;
    9998  }
    10099   
    101100  if (object[0].etype & 0x01) {
    102     DrawYErrors (graph, object);
     101    DrawYErrors (graphic, graph, object);
    103102  }
    104103  if (object[0].etype & 0x02) {
    105     DrawXErrors (graph, object);
    106   }
    107 
    108   XSetLineAttributes (graphic->display, graphic->gc, 0, LineSolid, CAPSTYLE, JOINSTYLE);
    109   XSetForeground (graphic->display, graphic->gc, graphic->fore);
     104    DrawXErrors (graphic, graph, object);
     105  }
    110106  return (TRUE);
    111107}
    112108
    113109/******/
    114 void DrawConnect (KapaGraphWidget *graph, Gobjects *object) {
     110void DrawConnect (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    115111 
    116112  int i;
     
    149145    sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
    150146   
    151     ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     147    ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    152148    /* DrawLine (sx0, sy0, sx1, sy1); */
    153149    sx0 = sx1; sy0 = sy1;
     
    156152}
    157153
    158 void ClipLine (double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {
     154void ClipLine (Graphic *graphic, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {
    159155
    160156  /* skip line segement if both points are beyond box */
     
    212208/* simplify the code abit by finding triplets, watch out for a histogram of 2 points */
    213209# if (1)
    214 void DrawHistogram (KapaGraphWidget *graph, Gobjects *object) {
     210void DrawHistogram (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    215211
    216212  int i;
     
    298294# else
    299295
    300 void DrawHistogram (KapaGraphWidget *graph, Gobjects *object) {
     296void DrawHistogram (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    301297
    302298  int i;
     
    407403
    408404/******/
    409 void DrawPoints (KapaGraphWidget *graph, Gobjects *object) {
     405void DrawPoints (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    410406
    411407  int i;
     
    427423  by = byi + byj;
    428424 
    429   Graphic *graphic = GetGraphic();
    430 
    431   /**** points are scaled by object.z ***/
     425  /**** point sizes are scaled by object.size, colors by object.color ***/
    432426  int scaleSize = (object[0].size < 0);
    433427  int scaleColor = (object[0].color < 0);
     
    437431  x = object[0].x; y = object[0].y; z = object[0].z;
    438432
    439   if (object[0].ptype == 0) {   /* filled box */
    440     for (i = 0; i < object[0].Npts; i++) {
    441       if (!(finite(x[i]) && finite(y[i]))) continue;
    442       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    443       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    444       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    445           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    446         if (scaleColor) {
    447           if (!finite(z[i])) continue;
    448           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    449           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    450         }
    451         D = scaleSize ? dz*z[i] : ds;
    452         FillRectangle (sx - D, sy - D, 2*D + 1, 2*D + 1);
    453       }
     433  switch (object[0].ptype) {
     434    case KAPA_POINT_BOX_OPEN:   /* open box */
     435      for (i = 0; i < object[0].Npts; i++) {
     436        if (!(finite(x[i]) && finite(y[i]))) continue;
     437        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     438        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     439        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     440            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     441          if (scaleColor) {
     442            if (!finite(z[i])) continue;
     443            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     444            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     445          }
     446          D = scaleSize ? dz*z[i] : ds;
     447          DrawRectangle (sx - D, sy - D, 2*D, 2*D);
     448        }
     449      }
     450      break;
     451    case KAPA_POINT_CROSS: /* cross */
     452      for (i = 0; i < object[0].Npts; i++) {
     453        if (!(finite(x[i]) && finite(y[i]))) continue;
     454        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     455        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     456        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     457            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     458          if (scaleColor) {
     459            if (!finite(z[i])) continue;
     460            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     461            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     462          }
     463          D = scaleSize ? dz*z[i] : ds;
     464          DrawLine (sx - D, sy, sx + D + 1, sy);
     465          DrawLine (sx, sy - D, sx, sy + D + 1);
     466        }
     467      }
     468      break;
     469    case KAPA_POINT_X:  /* x */
     470      for (i = 0; i < object[0].Npts; i++) {
     471        if (!(finite(x[i]) && finite(y[i]))) continue;
     472        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     473        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     474        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     475            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     476          if (scaleColor) {
     477            if (!finite(z[i])) continue;
     478            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     479            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     480          }
     481          D = scaleSize ? dz*z[i] : ds;
     482          DrawLine (sx - D, sy + D, sx + D + 1, sy - D - 1);
     483          DrawLine (sx - D, sy - D, sx + D + 1, sy + D + 1);
     484        }
     485      }
     486      break;
     487    case KAPA_POINT_TRIANGLE_SOLID:     /* filled triangle */
     488      for (i = 0; i < object[0].Npts; i++) {
     489        if (!(finite(x[i]) && finite(y[i]))) continue;
     490        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     491        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     492        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     493            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     494          if (scaleColor) {
     495            if (!finite(z[i])) continue;
     496            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     497            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     498          }
     499          D = scaleSize ? dz*z[i] : ds;
     500
     501          XPoint points[4];
     502          points[0].x = sx - D;  points[0].y = sy + 0.58*D; 
     503          points[1].x = sx + D;  points[1].y = sy + 0.58*D; 
     504          points[2].x = sx;      points[2].y = sy - 1.15*D; 
     505          points[3].x = sx - D;  points[3].y = sy + 0.58*D; 
     506          XFillPolygon (graphic->display, graphic->window, graphic->gc, points, 4, Convex, CoordModeOrigin);
     507        }
     508      }
     509      break;
     510    case KAPA_POINT_TRIANGLE_SOLID_DOWN: /* filled triangle (down) */
     511      for (i = 0; i < object[0].Npts; i++) {
     512        if (!(finite(x[i]) && finite(y[i]))) continue;
     513        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     514        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     515        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     516            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     517          if (scaleColor) {
     518            if (!finite(z[i])) continue;
     519            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     520            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     521          }
     522          D = scaleSize ? dz*z[i] : ds;
     523
     524          XPoint points[4];
     525          points[0].x = sx - D;  points[0].y = sy - 0.58*D; 
     526          points[1].x = sx + D;  points[1].y = sy - 0.58*D; 
     527          points[2].x = sx;      points[2].y = sy + 1.15*D; 
     528          points[3].x = sx - D;  points[3].y = sy - 0.58*D; 
     529          XFillPolygon (graphic->display, graphic->window, graphic->gc, points, 4, Convex, CoordModeOrigin);
     530        }
     531      }
     532      break;
     533    case KAPA_POINT_TRIANGLE_OPEN:      /* open triangle */
     534      for (i = 0; i < object[0].Npts; i++) {
     535        if (!(finite(x[i]) && finite(y[i]))) continue;
     536        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     537        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     538        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     539            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     540          if (scaleColor) {
     541            if (!finite(z[i])) continue;
     542            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     543            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     544          }
     545          D = scaleSize ? dz*z[i] : ds;
     546          DrawLine (sx - D, sy + 0.58*D, sx + D, sy + 0.58*D);
     547          DrawLine (sx + D, sy + 0.58*D, sx,     sy - 1.15*D);
     548          DrawLine (sx,     sy - 1.15*D, sx - D, sy + 0.58*D);
     549        }
     550      }
     551      break;
     552    case KAPA_POINT_TRIANGLE_OPEN_DOWN: /* upside-down open triangle */
     553      for (i = 0; i < object[0].Npts; i++) {
     554        if (!(finite(x[i]) && finite(y[i]))) continue;
     555        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     556        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     557        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     558            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     559          if (scaleColor) {
     560            if (!finite(z[i])) continue;
     561            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     562            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     563          }
     564          D = scaleSize ? dz*z[i] : ds;
     565          DrawLine (sx - D, sy - 0.58*D, sx + D, sy - 0.58*D);
     566          DrawLine (sx + D, sy - 0.58*D, sx,     sy + 1.15*D);
     567          DrawLine (sx,     sy + 1.15*D, sx - D, sy - 0.58*D);
     568        }
     569      }
     570      break;
     571    case KAPA_POINT_Y:  /* Y */
     572      for (i = 0; i < object[0].Npts; i++) {
     573        if (!(finite(x[i]) && finite(y[i]))) continue;
     574        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     575        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     576        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     577            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     578          if (scaleColor) {
     579            if (!finite(z[i])) continue;
     580            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     581            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     582          }
     583          D = scaleSize ? dz*z[i] : ds;
     584          DrawLine (sx, sy, sx - D, sy - 0.58*D);
     585          DrawLine (sx, sy, sx + D, sy - 0.58*D);
     586          DrawLine (sx, sy, sx,     sy + 1.15*D);
     587        }
     588      }
     589      break;
     590    case KAPA_POINT_Y_DOWN:     /* upside-down Y */
     591      for (i = 0; i < object[0].Npts; i++) {
     592        if (!(finite(x[i]) && finite(y[i]))) continue;
     593        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     594        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     595        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     596            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     597          if (scaleColor) {
     598            if (!finite(z[i])) continue;
     599            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     600            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     601          }
     602          D = scaleSize ? dz*z[i] : ds;
     603          DrawLine (sx, sy, sx - D, sy + 0.58*D);
     604          DrawLine (sx, sy, sx + D, sy + 0.58*D);
     605          DrawLine (sx, sy, sx,     sy - 1.15*D);
     606        }
     607      }
     608      break;
     609    case KAPA_POINT_CIRCLE_OPEN: /* 0 */
     610      for (i = 0; i < object[0].Npts; i++) {
     611        if (!(finite(x[i]) && finite(y[i]))) continue;
     612        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     613        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     614        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     615            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     616          if (scaleColor) {
     617            if (!finite(z[i])) continue;
     618            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     619            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     620          }
     621          D = scaleSize ? dz*z[i] : ds;
     622          DrawCircle (sx, sy, D);
     623        }
     624      }
     625      break;
     626    case KAPA_POINT_CIRCLE_SOLID: /* filled 0 */
     627      for (i = 0; i < object[0].Npts; i++) {
     628        if (!(finite(x[i]) && finite(y[i]))) continue;
     629        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     630        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     631        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     632            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     633          if (scaleColor) {
     634            if (!finite(z[i])) continue;
     635            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     636            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     637          }
     638          D = scaleSize ? dz*z[i] : ds;
     639          FillCircle (sx, sy, D);
     640          DrawCircle (sx, sy, D);
     641        }
     642      }
     643      break;
     644    case KAPA_POINT_PENTAGON:   /* pentagon */
     645      for (i = 0; i < object[0].Npts; i++) {
     646        if (!(finite(x[i]) && finite(y[i]))) continue;
     647        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     648        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     649        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     650            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     651          if (scaleColor) {
     652            if (!finite(z[i])) continue;
     653            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     654            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     655          }
     656          D = scaleSize ? dz*z[i] : ds;
     657          DrawLine (sx + 0.00*D, sy - 1.00*D, sx + 0.95*D, sy - 0.31*D);
     658          DrawLine (sx + 0.95*D, sy - 0.31*D, sx + 0.58*D, sy + 0.81*D);
     659          DrawLine (sx + 0.58*D, sy + 0.81*D, sx - 0.58*D, sy + 0.81*D);
     660          DrawLine (sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D);
     661          DrawLine (sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D);
     662        }
     663      }
     664      break;
     665    case KAPA_POINT_HEXAGON:    /* hexagon */
     666      for (i = 0; i < object[0].Npts; i++) {
     667        if (!(finite(x[i]) && finite(y[i]))) continue;
     668        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     669        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     670        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     671            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     672          if (scaleColor) {
     673            if (!finite(z[i])) continue;
     674            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     675            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     676          }
     677          D = scaleSize ? dz*z[i] : ds;
     678          DrawLine (sx -      D, sy,          sx - 0.50*D, sy + 0.87*D);
     679          DrawLine (sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D);
     680          DrawLine (sx + 0.50*D, sy + 0.87*D, sx +      D, sy);
     681
     682          DrawLine (sx +      D, sy,          sx + 0.50*D, sy - 0.87*D);
     683          DrawLine (sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D);
     684          DrawLine (sx - 0.50*D, sy - 0.87*D, sx -      D, sy);
     685        }
     686      }
     687      break;
     688    case KAPA_POINT_PAIR_CONNECT: { /* connect pairs of points */
     689      double X0 = graph[0].axis[0].fx;
     690      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     691      double Y0 = graph[0].axis[1].fy;
     692      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     693
     694      for (i = 0; i + 1 < object[0].Npts; i+=2) {
     695        if (!(finite(x[i]) && finite(y[i]))) continue;
     696        sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     697        sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
     698        if (!(finite(x[i+1]) && finite(y[i+1]))) continue;
     699        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx + XCENTER;
     700        sy2 = x[i+1]*myi + y[i+1]*myj + by + YCENTER;
     701        ClipLine (graphic, sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
     702      }
     703      break;
    454704    }
    455   }
    456   if (object[0].ptype == 1) {   /* open box */
    457     for (i = 0; i < object[0].Npts; i++) {
    458       if (!(finite(x[i]) && finite(y[i]))) continue;
    459       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    460       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    461       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    462           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    463         if (scaleColor) {
    464           if (!finite(z[i])) continue;
    465           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    466           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    467         }
    468         D = scaleSize ? dz*z[i] : ds;
    469         DrawRectangle (sx - D, sy - D, 2*D, 2*D);
    470       }
    471     }
    472   }
    473   if (object[0].ptype == 2) { /* cross */
    474     for (i = 0; i < object[0].Npts; i++) {
    475       if (!(finite(x[i]) && finite(y[i]))) continue;
    476       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    477       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    478       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    479           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    480         if (scaleColor) {
    481           if (!finite(z[i])) continue;
    482           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    483           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    484         }
    485         D = scaleSize ? dz*z[i] : ds;
    486         DrawLine (sx - D, sy, sx + D + 1, sy);
    487         DrawLine (sx, sy - D, sx, sy + D + 1);
    488       }
    489     }
    490   }
    491   if (object[0].ptype == 3) {   /* x */
    492     for (i = 0; i < object[0].Npts; i++) {
    493       if (!(finite(x[i]) && finite(y[i]))) continue;
    494       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    495       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    496       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    497           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    498         if (scaleColor) {
    499           if (!finite(z[i])) continue;
    500           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    501           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    502         }
    503         D = scaleSize ? dz*z[i] : ds;
    504         DrawLine (sx - D, sy + D, sx + D + 1, sy - D - 1);
    505         DrawLine (sx - D, sy - D, sx + D + 1, sy + D + 1);
    506       }
    507     }
    508   }
    509   if (object[0].ptype == 4) {   /* filled triangle */
    510     XPoint points[4];
    511     for (i = 0; i < object[0].Npts; i++) {
    512       if (!(finite(x[i]) && finite(y[i]))) continue;
    513       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    514       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    515       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    516           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    517         if (scaleColor) {
    518           if (!finite(z[i])) continue;
    519           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    520           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    521         }
    522         D = scaleSize ? dz*z[i] : ds;
    523         points[0].x = sx - D;  points[0].y = sy + 0.58*D; 
    524         points[1].x = sx + D;  points[1].y = sy + 0.58*D; 
    525         points[2].x = sx;      points[2].y = sy - 1.15*D; 
    526         points[3].x = sx - D;  points[3].y = sy + 0.58*D; 
    527         XFillPolygon (graphic->display, graphic->window, graphic->gc, points, 4, Convex, CoordModeOrigin);
    528       }
    529     }
    530   }
    531   if (object[0].ptype == 5) {   /* open triangle */
    532     for (i = 0; i < object[0].Npts; i++) {
    533       if (!(finite(x[i]) && finite(y[i]))) continue;
    534       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    535       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    536       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    537           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    538         if (scaleColor) {
    539           if (!finite(z[i])) continue;
    540           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    541           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    542         }
    543         D = scaleSize ? dz*z[i] : ds;
    544         DrawLine (sx - D, sy + 0.58*D, sx + D, sy + 0.58*D);
    545         DrawLine (sx + D, sy + 0.58*D, sx,     sy - 1.15*D);
    546         DrawLine (sx,     sy - 1.15*D, sx - D, sy + 0.58*D);
    547       }
    548     }
    549   }
    550   if (object[0].ptype == 6) {   /* Y */
    551     for (i = 0; i < object[0].Npts; i++) {
    552       if (!(finite(x[i]) && finite(y[i]))) continue;
    553       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    554       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    555       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    556           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    557         if (scaleColor) {
    558           if (!finite(z[i])) continue;
    559           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    560           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    561         }
    562         D = scaleSize ? dz*z[i] : ds;
    563         DrawLine (sx, sy, sx - D, sy - 0.58*D);
    564         DrawLine (sx, sy, sx + D, sy - 0.58*D);
    565         DrawLine (sx, sy, sx,     sy + 1.15*D);
    566       }
    567     }
    568   }
    569   if (object[0].ptype == 7) {   /* 0 */
    570     for (i = 0; i < object[0].Npts; i++) {
    571       if (!(finite(x[i]) && finite(y[i]))) continue;
    572       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    573       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    574       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    575           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    576         if (scaleColor) {
    577           if (!finite(z[i])) continue;
    578           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    579           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    580         }
    581         D = scaleSize ? dz*z[i] : ds;
    582         DrawCircle (sx, sy, D);
    583       }
    584     }
    585   }
    586   if (object[0].ptype == 8) {   /* pentagon */
    587     for (i = 0; i < object[0].Npts; i++) {
    588       if (!(finite(x[i]) && finite(y[i]))) continue;
    589       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    590       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    591       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    592           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    593         if (scaleColor) {
    594           if (!finite(z[i])) continue;
    595           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    596           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    597         }
    598         D = scaleSize ? dz*z[i] : ds;
    599         DrawLine (sx + 0.00*D, sy - 1.00*D, sx + 0.95*D, sy - 0.31*D);
    600         DrawLine (sx + 0.95*D, sy - 0.31*D, sx + 0.58*D, sy + 0.81*D);
    601         DrawLine (sx + 0.58*D, sy + 0.81*D, sx - 0.58*D, sy + 0.81*D);
    602         DrawLine (sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D);
    603         DrawLine (sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D);
    604       }
    605     }
    606   }
    607   if (object[0].ptype == 9) {   /* hexagon */
    608     for (i = 0; i < object[0].Npts; i++) {
    609       if (!(finite(x[i]) && finite(y[i]))) continue;
    610       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    611       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    612       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    613           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    614         if (scaleColor) {
    615           if (!finite(z[i])) continue;
    616           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    617           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    618         }
    619         D = scaleSize ? dz*z[i] : ds;
    620         DrawLine (sx -      D, sy,          sx - 0.50*D, sy + 0.87*D);
    621         DrawLine (sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D);
    622         DrawLine (sx + 0.50*D, sy + 0.87*D, sx +      D, sy);
    623 
    624         DrawLine (sx +      D, sy,          sx + 0.50*D, sy - 0.87*D);
    625         DrawLine (sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D);
    626         DrawLine (sx - 0.50*D, sy - 0.87*D, sx -      D, sy);
    627       }
    628     }
    629   }
    630   if (object[0].ptype == 10) {  /* filled 0 */
    631     for (i = 0; i < object[0].Npts; i++) {
    632       if (!(finite(x[i]) && finite(y[i]))) continue;
    633       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    634       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    635       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    636           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    637         if (scaleColor) {
    638           if (!finite(z[i])) continue;
    639           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    640           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    641         }
    642         D = scaleSize ? dz*z[i] : ds;
    643         FillCircle (sx, sy, D);
    644       }
    645     }
    646   }
    647   if (object[0].ptype == 12) {  /* filled triangle (down) */
    648     XPoint points[4];
    649     for (i = 0; i < object[0].Npts; i++) {
    650       if (!(finite(x[i]) && finite(y[i]))) continue;
    651       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    652       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    653       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    654           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    655         if (scaleColor) {
    656           if (!finite(z[i])) continue;
    657           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    658           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    659         }
    660         D = scaleSize ? dz*z[i] : ds;
    661         points[0].x = sx - D;  points[0].y = sy - 0.58*D; 
    662         points[1].x = sx + D;  points[1].y = sy - 0.58*D; 
    663         points[2].x = sx;      points[2].y = sy + 1.15*D; 
    664         points[3].x = sx - D;  points[3].y = sy - 0.58*D; 
    665         XFillPolygon (graphic->display, graphic->window, graphic->gc, points, 4, Convex, CoordModeOrigin);
    666       }
    667     }
    668   }
    669   if (object[0].ptype == 14) {  /* upside-down filled triangle */
    670     XPoint points[4];
    671     for (i = 0; i < object[0].Npts; i++) {
    672       if (!(finite(x[i]) && finite(y[i]))) continue;
    673       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    674       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    675       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    676           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    677         if (scaleColor) {
    678           if (!finite(z[i])) continue;
    679           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    680           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    681         }
    682         D = scaleSize ? dz*z[i] : ds;
    683         points[0].x = sx - D;  points[0].y = sy - 0.58*D; 
    684         points[1].x = sx + D;  points[1].y = sy - 0.58*D; 
    685         points[2].x = sx;      points[2].y = sy + 1.15*D; 
    686         points[3].x = sx - D;  points[3].y = sy - 0.58*D; 
    687         XFillPolygon (graphic->display, graphic->window, graphic->gc, points, 4, Convex, CoordModeOrigin);
    688       }
    689     }
    690   }
    691   if (object[0].ptype == 15) {  /* upside-down open triangle */
    692     for (i = 0; i < object[0].Npts; i++) {
    693       if (!(finite(x[i]) && finite(y[i]))) continue;
    694       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    695       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    696       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    697           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    698         if (scaleColor) {
    699           if (!finite(z[i])) continue;
    700           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    701           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    702         }
    703         D = scaleSize ? dz*z[i] : ds;
    704         DrawLine (sx - D, sy - 0.58*D, sx + D, sy - 0.58*D);
    705         DrawLine (sx + D, sy - 0.58*D, sx,     sy + 1.15*D);
    706         DrawLine (sx,     sy + 1.15*D, sx - D, sy - 0.58*D);
    707       }
    708     }
    709   }
    710   if (object[0].ptype == 16) {  /* upside-down Y */
    711     for (i = 0; i < object[0].Npts; i++) {
    712       if (!(finite(x[i]) && finite(y[i]))) continue;
    713       sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    714       sy = x[i]*myi + y[i]*myj + by + YCENTER;
    715       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    716           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
    717         if (scaleColor) {
    718           if (!finite(z[i])) continue;
    719           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    720           XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
    721         }
    722         D = scaleSize ? dz*z[i] : ds;
    723         DrawLine (sx, sy, sx - D, sy + 0.58*D);
    724         DrawLine (sx, sy, sx + D, sy + 0.58*D);
    725         DrawLine (sx, sy, sx,     sy - 1.15*D);
    726       }
    727     }
    728   }
    729   if (object[0].ptype == 100) { /* connect a pair of points */
    730 
    731     double X0 = graph[0].axis[0].fx;
    732     double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
    733     double Y0 = graph[0].axis[1].fy;
    734     double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    735 
    736     for (i = 0; i + 1 < object[0].Npts; i+=2) {
    737       if (!(finite(x[i]) && finite(y[i]))) continue;
    738       sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    739       sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
    740       if (!(finite(x[i+1]) && finite(y[i+1]))) continue;
    741       sx2 = x[i+1]*mxi + y[i+1]*mxj + bx + XCENTER;
    742       sy2 = x[i+1]*myi + y[i+1]*myj + by + YCENTER;
    743       ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
    744     }
     705    case KAPA_POINT_BOX_SOLID:  /* filled box */
     706    default:
     707      for (i = 0; i < object[0].Npts; i++) {
     708        if (!(finite(x[i]) && finite(y[i]))) continue;
     709        sx = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     710        sy = x[i]*myi + y[i]*myj + by + YCENTER;
     711        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     712            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     713          if (scaleColor) {
     714            if (!finite(z[i])) continue;
     715            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     716            XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     717          }
     718          D = scaleSize ? dz*z[i] : ds;
     719          FillRectangle (sx - D, sy - D, 2*D + 1, 2*D + 1);
     720        }
     721      }
     722      break;
    745723  }
    746724}
    747725   
    748726/******/
    749 void DrawXErrors (KapaGraphWidget *graph, Gobjects *object) {
     727void DrawXErrors (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    750728 
    751729  int i, bar, dz, ds, D;
     
    800778         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    801779    {
    802       ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     780      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    803781      if (bar) {
    804782        sx10 = sy1 - sz;
    805783        sx11 = sy1 + sz;
    806         ClipLine (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
     784        ClipLine (graphic, sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
    807785      }
    808786    }
     
    819797         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    820798    {
    821       ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     799      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    822800      if (bar) {
    823801        sx10 = sy1 - sz;
    824802        sx11 = sy1 + sz;
    825         ClipLine (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
     803        ClipLine (graphic, sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
    826804      }
    827805    }
     
    830808   
    831809/******/
    832 void DrawYErrors (KapaGraphWidget *graph, Gobjects *object) {
     810void DrawYErrors (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    833811
    834812  int i, bar, dz, ds, D;
     
    883861         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    884862    {
    885       ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     863      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    886864      if (bar) {
    887865        sx10 = sx1 - sz;
    888866        sx11 = sx1 + sz;
    889         ClipLine (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
     867        ClipLine (graphic, sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
    890868      }
    891869    }
     
    904882         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    905883    {
    906       ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     884      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    907885      if (bar) {
    908886        sx10 = sx1 - sz;
    909887        sx11 = sx1 + sz;
    910         ClipLine (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
     888        ClipLine (graphic, sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
    911889      }
    912890    }
  • trunk/Ohana/src/kapa2/src/LoadObject.c

    r31665 r39926  
    102102  if (DEBUG) fprintf (stderr, "loaded %d objects, using object %d\n", graph[0].objects[N].Npts, N);
    103103
    104   if (USE_XWINDOW) DrawObjectN (graph, &graph[0].objects[graph[0].Nobjects-1]);
     104  if (USE_XWINDOW) {
     105    Graphic *graphic = GetGraphic();
     106    DrawObjectN (graphic, graph, &graph[0].objects[graph[0].Nobjects-1]);
     107  }
    105108  FlushDisplay ();
    106109
  • trunk/Ohana/src/kapa2/src/PSFrame.c

    r38986 r39926  
    1111
    1212  graphic = GetGraphic();
     13
     14  P = 0.5 * (1 + 0.25*graph[0].axis[0].lweight) * (hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy) + hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy));
    1315
    1416  /* each axis is drawn independently */
     
    3032    dfy = -graph[0].axis[i].dfy + 2*dy;
    3133
    32     P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    33     P *= (1 + 0.25*lweight);
     34    // P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
     35    // P *= (1 + 0.25*lweight);
    3436
    3537    fprintf (f, "%.1f setlinewidth\n", lweight);
  • trunk/Ohana/src/kapa2/src/PSObjects.c

    r38153 r39926  
    77# define FillCircle(X1,Y1,R) (fprintf (f, " %6.2f %6.2f %6.2f FC\n", (X1), (graphic->dy - Y1), (R)))
    88# define FillTriangle(X1,Y1,X2,Y2, X3, Y3) (fprintf (f, " %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f TF\n", (X1), (graphic->dy-Y1), (X2), (graphic->dy-Y2), (X3), (graphic->dy-Y3)))
    9 # define CONNECT 0
    10 # define HISTOGRAM 1
    11 # define POINTS 2
    12 
     9
     10# define CAPSTYLE 1 /* CapButt */
     11# define JOINSTYLE 0 /* JoinMiter */
     12
     13// XXX this is not thread safe, but that is OK
    1314static Graphic *graphic;
    1415
     
    1617 
    1718  int i;
    18   double lweight;
    19   static char dash[] = "5";
    20   static char dot[] = "3";
    21  
     19 
     20  // the functions below use this global value
    2221  graphic = GetGraphic();
    2322
     23  // this function calls all of the supporting Draw... functions below
    2424  for (i = 0; i < graph[0].Nobjects; i++) {
    25     switch (graph[0].objects[i].ltype) {
    26     case 0:
    27       break;
    28     case 1:
    29       fprintf (f, "[%s] 0 setdash\n", dash);
    30       break;
    31     case 2:
     25    PSObjectsN (graph, &graph[0].objects[i], f);
     26  }
     27  // reset to default color and style
     28  fprintf (f, "[] 0 setdash\n");
     29  fprintf (f, "0.00 0.00 0.00 setrgbcolor\n");
     30
     31  return (TRUE);
     32}
     33
     34int PSObjectsN (KapaGraphWidget *graph, Gobjects *object, FILE *f) {
     35 
     36  static char short_dash[] = "4 4";
     37  static char long_dash[] = "8 8";
     38  static char dot_dash[] = "2 4 4 4";
     39  static char dot[] = "2 3";
     40 
     41  double lweight = MAX (0, MIN (10, object->lweight));
     42  fprintf (f, "%.1f setlinewidth\n", lweight);
     43  fprintf (f, "%d setlinecap %d setlinejoin\n", CAPSTYLE, JOINSTYLE);
     44
     45  switch (object->ltype) {
     46    case KAPA_LINE_DOT:
    3247      fprintf (f, "[%s] 0 setdash\n", dot);
    3348      break;
     49    case KAPA_LINE_DASH_SHORT:
     50      fprintf (f, "[%s] 0 setdash\n", short_dash);
     51      break;
     52    case KAPA_LINE_DASH_LONG:
     53      fprintf (f, "[%s] 0 setdash\n", long_dash);
     54      break;
     55    case KAPA_LINE_DOT_DASH:
     56      fprintf (f, "[%s] 0 setdash\n", dot_dash);
     57      break;
     58    case KAPA_LINE_SOLID: // no need to call 'setdash' as solid is the default
    3459    default:
    3560      break;
    36     }
     61  }
    3762   
    38     lweight = MAX (0, MIN (10, graph[0].objects[i].lweight));
    39     fprintf (f, "%.1f setlinewidth\n", lweight);
    40 
    41     if (graph[0].objects[i].color >= 0) {
    42         fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(graph[0].objects[i].color));
    43     }
    44 
    45     switch (graph[0].objects[i].style) {
    46     case CONNECT:
    47       PSConnect (graph, &graph[0].objects[i], f);
    48       break;
    49     case HISTOGRAM:
    50       PSHistogram (graph, &graph[0].objects[i], f);
    51       break;
    52     case POINTS:
    53       PSPoints (graph, &graph[0].objects[i], f);
    54       break;
    55     }
    56 
    57     if (graph[0].objects[i].etype & 0x01) {
    58       PSYErrors (graph, &graph[0].objects[i], f);
    59     }
    60     if (graph[0].objects[i].etype & 0x02) {
    61       PSXErrors (graph, &graph[0].objects[i], f);
    62     }
    63     fprintf (f, "[] 0 setdash\n");
    64     fprintf (f, "0.00 0.00 0.00 setrgbcolor\n");
     63  if (object->color >= 0) {
     64    fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(object->color));
     65  }
     66
     67  switch (object->style) {
     68    case KAPA_PLOT_CONNECT:
     69      PSConnect (graph, object, f);
     70      break;
     71    case KAPA_PLOT_HISTOGRAM:
     72      PSHistogram (graph, object, f);
     73      break;
     74    case KAPA_PLOT_POINTS:
     75    default:
     76      PSPoints (graph, object, f);
     77      break;
     78  }
     79
     80  if (object->etype & 0x01) {
     81    PSYErrors (graph, object, f);
     82  }
     83  if (object->etype & 0x02) {
     84    PSXErrors (graph, object, f);
    6585  }
    6686  return (TRUE);
     
    303323  }
    304324
    305   // black, I think
    306325  // fprintf (f, "0.00 0.00 0.00 setrgbcolor\n");
    307326
    308   /**** points are scaled by object.z ***/
     327  /**** point sizes are scaled by object.size, colors by object.color ***/
    309328  int scaleSize = (object[0].size < 0);
    310329  int scaleColor = (object[0].color < 0);
     
    314333  x = object[0].x; y = object[0].y; z = object[0].z;
    315334
    316   if (object[0].ptype == 0) {   /* filled box */
    317     for (i = 0; i < object[0].Npts; i++) {
    318       if (!(finite(x[i]) && finite(y[i]))) continue;
    319       sx = x[i]*mxi + y[i]*mxj + bx;
    320       sy = x[i]*myi + y[i]*myj + by;
    321       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    322           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    323       {
    324         if (scaleColor) {
    325           if (!finite(z[i])) continue;
    326           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    327           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    328         }
    329         D = scaleSize ? dz*z[i] : ds;
    330         FillRectangle (sx, sy, 2*D, 2*D);
    331       }
     335  switch (object[0].ptype) {
     336    case KAPA_POINT_BOX_OPEN:   /* open box */
     337      for (i = 0; i < object[0].Npts; i++) {
     338        if (!(finite(x[i]) && finite(y[i]))) continue;
     339        sx = x[i]*mxi + y[i]*mxj + bx;
     340        sy = x[i]*myi + y[i]*myj + by;
     341        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     342            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     343          if (scaleColor) {
     344            if (!finite(z[i])) continue;
     345            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     346            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     347          }
     348          D = scaleSize ? dz*z[i] : ds;
     349          DrawRectangle (sx, sy, 2*D, 2*D);
     350        }
     351      }
     352      break;
     353    case KAPA_POINT_CROSS: /* cross */
     354      for (i = 0; i < object[0].Npts; i++) {
     355        if (!(finite(x[i]) && finite(y[i]))) continue;
     356        sx = x[i]*mxi + y[i]*mxj + bx;
     357        sy = x[i]*myi + y[i]*myj + by;
     358        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     359            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     360          if (scaleColor) {
     361            if (!finite(z[i])) continue;
     362            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     363            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     364          }
     365          D = scaleSize ? dz*z[i] : ds;
     366          DrawLine (sx - D, sy, sx + D, sy);
     367          DrawLine (sx, sy - D, sx, sy + D);
     368        }
     369      }
     370      break;
     371    case KAPA_POINT_X:  /* x */
     372      for (i = 0; i < object[0].Npts; i++) {
     373        if (!(finite(x[i]) && finite(y[i]))) continue;
     374        sx = x[i]*mxi + y[i]*mxj + bx;
     375        sy = x[i]*myi + y[i]*myj + by;
     376        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     377            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     378          if (scaleColor) {
     379            if (!finite(z[i])) continue;
     380            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     381            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     382          }
     383          D = scaleSize ? dz*z[i] : ds;
     384          DrawLine (sx + D, sy - D, sx - D, sy + D);
     385          DrawLine (sx - D, sy - D, sx + D, sy + D);
     386        }
     387      }
     388      break;
     389    case KAPA_POINT_TRIANGLE_SOLID:     /* filled triangle */
     390      for (i = 0; i < object[0].Npts; i++) {
     391        if (!(finite(x[i]) && finite(y[i]))) continue;
     392        sx = x[i]*mxi + y[i]*mxj + bx;
     393        sy = x[i]*myi + y[i]*myj + by;
     394        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     395            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     396          if (scaleColor) {
     397            if (!finite(z[i])) continue;
     398            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     399            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     400          }
     401          D = scaleSize ? dz*z[i] : ds;
     402          FillTriangle (sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
     403        }
     404      }
     405      break;
     406    case KAPA_POINT_TRIANGLE_SOLID_DOWN:        /* open triangle */
     407      for (i = 0; i < object[0].Npts; i++) {
     408        if (!(finite(x[i]) && finite(y[i]))) continue;
     409        sx = x[i]*mxi + y[i]*mxj + bx;
     410        sy = x[i]*myi + y[i]*myj + by;
     411        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     412            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     413          if (scaleColor) {
     414            if (!finite(z[i])) continue;
     415            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     416            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     417          }
     418          D = scaleSize ? dz*z[i] : ds;
     419          FillTriangle (sx - D, sy + 0.58*D, sx + D, sy + 0.58*D, sx, sy - 1.15*D);
     420        }
     421      }
     422      break;
     423    case KAPA_POINT_TRIANGLE_OPEN:      /* open triangle */
     424      for (i = 0; i < object[0].Npts; i++) {
     425        if (!(finite(x[i]) && finite(y[i]))) continue;
     426        sx = x[i]*mxi + y[i]*mxj + bx;
     427        sy = x[i]*myi + y[i]*myj + by;
     428        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     429            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     430          if (scaleColor) {
     431            if (!finite(z[i])) continue;
     432            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     433            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     434          }
     435          D = scaleSize ? dz*z[i] : ds;
     436          DrawLine (sx - D, sy - 0.58*D, sx + D, sy - 0.58*D);
     437          DrawLine (sx + D, sy - 0.58*D, sx,     sy + 1.15*D);
     438          DrawLine (sx,     sy + 1.15*D, sx - D, sy - 0.58*D);
     439        }
     440      }
     441      break;
     442    case KAPA_POINT_TRIANGLE_OPEN_DOWN: /* upside-down open triangle */
     443      for (i = 0; i < object[0].Npts; i++) {
     444        if (!(finite(x[i]) && finite(y[i]))) continue;
     445        sx = x[i]*mxi + y[i]*mxj + bx;
     446        sy = x[i]*myi + y[i]*myj + by;
     447        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     448            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     449          if (scaleColor) {
     450            if (!finite(z[i])) continue;
     451            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     452            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     453          }
     454          D = scaleSize ? dz*z[i] : ds;
     455          DrawLine (sx - D, sy + 0.58*D, sx + D, sy + 0.58*D);
     456          DrawLine (sx + D, sy + 0.58*D, sx,     sy - 1.15*D);
     457          DrawLine (sx,     sy - 1.15*D, sx - D, sy + 0.58*D);
     458        }
     459      }
     460      break;
     461    case KAPA_POINT_Y:  /* Y */
     462      for (i = 0; i < object[0].Npts; i++) {
     463        if (!(finite(x[i]) && finite(y[i]))) continue;
     464        sx = x[i]*mxi + y[i]*mxj + bx;
     465        sy = x[i]*myi + y[i]*myj + by;
     466        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     467            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     468          if (scaleColor) {
     469            if (!finite(z[i])) continue;
     470            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     471            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     472          }
     473          D = scaleSize ? dz*z[i] : ds;
     474          DrawLine (sx, sy, sx - D, sy + 0.58*D);
     475          DrawLine (sx, sy, sx + D, sy + 0.58*D);
     476          DrawLine (sx, sy, sx,          sy - 1.15*D);
     477        }
     478      }
     479      break;
     480    case KAPA_POINT_Y_DOWN:     /* upside-down Y */
     481      for (i = 0; i < object[0].Npts; i++) {
     482        if (!(finite(x[i]) && finite(y[i]))) continue;
     483        sx = x[i]*mxi + y[i]*mxj + bx;
     484        sy = x[i]*myi + y[i]*myj + by;
     485        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     486            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     487          if (scaleColor) {
     488            if (!finite(z[i])) continue;
     489            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     490            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     491          }
     492          D = scaleSize ? dz*z[i] : ds;
     493          DrawLine (sx, sy, sx - D, sy - 0.58*D);
     494          DrawLine (sx, sy, sx + D, sy - 0.58*D);
     495          DrawLine (sx, sy, sx,     sy + 1.15*D);
     496        }
     497      }
     498      break;
     499    case KAPA_POINT_CIRCLE_OPEN: /* 0 */
     500      for (i = 0; i < object[0].Npts; i++) {
     501        if (!(finite(x[i]) && finite(y[i]))) continue;
     502        sx = x[i]*mxi + y[i]*mxj + bx;
     503        sy = x[i]*myi + y[i]*myj + by;
     504        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     505            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     506          if (scaleColor) {
     507            if (!finite(z[i])) continue;
     508            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     509            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     510          }
     511          D = scaleSize ? dz*z[i] : ds;
     512          DrawCircle (sx, sy, D);
     513        }
     514      }
     515      break;
     516    case KAPA_POINT_CIRCLE_SOLID: /* filled 0 */
     517      for (i = 0; i < object[0].Npts; i++) {
     518        if (!(finite(x[i]) && finite(y[i]))) continue;
     519        sx = x[i]*mxi + y[i]*mxj + bx;
     520        sy = x[i]*myi + y[i]*myj + by;
     521        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     522            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     523          if (scaleColor) {
     524            if (!finite(z[i])) continue;
     525            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     526            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     527          }
     528          D = scaleSize ? dz*z[i] : ds;
     529          FillCircle (sx, sy, D);
     530        }
     531      }
     532      break;
     533    case KAPA_POINT_PENTAGON:   /* pentagon */
     534      for (i = 0; i < object[0].Npts; i++) {
     535        if (!(finite(x[i]) && finite(y[i]))) continue;
     536        sx = x[i]*mxi + y[i]*mxj + bx;
     537        sy = x[i]*myi + y[i]*myj + by;
     538        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     539            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     540          if (scaleColor) {
     541            if (!finite(z[i])) continue;
     542            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     543            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     544          }
     545          D = scaleSize ? dz*z[i] : ds;
     546          DrawLine (sx + 0.00*D, sy + 1.00*D, sx + 0.95*D, sy + 0.31*D);
     547          DrawLine (sx + 0.95*D, sy + 0.31*D, sx + 0.58*D, sy - 0.81*D);
     548          DrawLine (sx + 0.58*D, sy - 0.81*D, sx - 0.58*D, sy - 0.81*D);
     549          DrawLine (sx - 0.58*D, sy - 0.81*D, sx - 0.95*D, sy + 0.31*D);
     550          DrawLine (sx - 0.95*D, sy + 0.31*D, sx + 0.00*D, sy + 1.00*D);
     551        }
     552      }
     553      break;
     554    case KAPA_POINT_HEXAGON:    /* hexagon */
     555      for (i = 0; i < object[0].Npts; i++) {
     556        if (!(finite(x[i]) && finite(y[i]))) continue;
     557        sx = x[i]*mxi + y[i]*mxj + bx;
     558        sy = x[i]*myi + y[i]*myj + by;
     559        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     560            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     561          if (scaleColor) {
     562            if (!finite(z[i])) continue;
     563            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     564            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     565          }
     566          D = scaleSize ? dz*z[i] : ds;
     567          DrawLine (sx -      D, sy,               sx - 0.50*D, sy + 0.87*D);
     568          DrawLine (sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D);
     569          DrawLine (sx + 0.50*D, sy + 0.87*D, sx +      D, sy);
     570
     571          DrawLine (sx +      D, sy,               sx + 0.50*D, sy - 0.87*D);
     572          DrawLine (sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D);
     573          DrawLine (sx - 0.50*D, sy - 0.87*D, sx -      D, sy);
     574        }
     575      }
     576      break;
     577    case KAPA_POINT_PAIR_CONNECT: { /* connect pairs of points */
     578      double X0 = graph[0].axis[0].fx;
     579      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     580      double Y0 = graph[0].axis[1].fy;
     581      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     582
     583      for (i = 0; i + 1 < object[0].Npts; i+=2) {
     584        if (!(finite(x[i]) && finite(y[i]))) continue;
     585        sx1 = x[i]*mxi + y[i]*mxj + bx;
     586        sy1 = x[i]*myi + y[i]*myj + by;
     587        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
     588        sy2 = x[i+1]*myi + y[i+1]*myj + by;
     589        ClipLinePS (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1, f);
     590      }
     591      break;
    332592    }
    333   }
    334   if (object[0].ptype == 1) {   /* open box */
    335     for (i = 0; i < object[0].Npts; i++) {
    336       if (!(finite(x[i]) && finite(y[i]))) continue;
    337       sx = x[i]*mxi + y[i]*mxj + bx;
    338       sy = x[i]*myi + y[i]*myj + by;
    339       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    340           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    341       {
    342         if (scaleColor) {
    343           if (!finite(z[i])) continue;
    344           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    345           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    346         }
    347         D = scaleSize ? dz*z[i] : ds;
    348         DrawRectangle (sx, sy, 2*D, 2*D);
    349       }
    350     }
    351   }
    352   if (object[0].ptype == 2) { /* cross */
    353     for (i = 0; i < object[0].Npts; i++) {
    354       if (!(finite(x[i]) && finite(y[i]))) continue;
    355       sx = x[i]*mxi + y[i]*mxj + bx;
    356       sy = x[i]*myi + y[i]*myj + by;
    357       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    358           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    359       {
    360         if (scaleColor) {
    361           if (!finite(z[i])) continue;
    362           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    363           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    364         }
    365         D = scaleSize ? dz*z[i] : ds;
    366         DrawLine (sx - D, sy, sx + D, sy);
    367         DrawLine (sx, sy - D, sx, sy + D);
    368       }
    369     }
    370   }
    371   if (object[0].ptype == 3) {   /* x */
    372     for (i = 0; i < object[0].Npts; i++) {
    373       if (!(finite(x[i]) && finite(y[i]))) continue;
    374       sx = x[i]*mxi + y[i]*mxj + bx;
    375       sy = x[i]*myi + y[i]*myj + by;
    376       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    377           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    378       {
    379         if (scaleColor) {
    380           if (!finite(z[i])) continue;
    381           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    382           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    383         }
    384         D = scaleSize ? dz*z[i] : ds;
    385         DrawLine (sx + D, sy - D, sx - D, sy + D);
    386         DrawLine (sx - D, sy - D, sx + D, sy + D);
    387       }
    388     }
    389   }
    390   if (object[0].ptype == 4) {   /* filled triangle */
    391     for (i = 0; i < object[0].Npts; i++) {
    392       if (!(finite(x[i]) && finite(y[i]))) continue;
    393       sx = x[i]*mxi + y[i]*mxj + bx;
    394       sy = x[i]*myi + y[i]*myj + by;
    395       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    396           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    397       {
    398         if (scaleColor) {
    399           if (!finite(z[i])) continue;
    400           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    401           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    402         }
    403         D = scaleSize ? dz*z[i] : ds;
    404         FillTriangle (sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
    405       }
    406     }
    407   }
    408   if (object[0].ptype == 14) {  /* filled triangle */
    409     for (i = 0; i < object[0].Npts; i++) {
    410       if (!(finite(x[i]) && finite(y[i]))) continue;
    411       sx = x[i]*mxi + y[i]*mxj + bx;
    412       sy = x[i]*myi + y[i]*myj + by;
    413       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    414           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    415       {
    416         if (scaleColor) {
    417           if (!finite(z[i])) continue;
    418           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    419           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    420         }
    421         D = scaleSize ? dz*z[i] : ds;
    422         FillTriangle (sx - D, sy + 0.58*D, sx + D, sy + 0.58*D, sx, sy - 1.15*D);
    423       }
    424     }
    425   }
    426   if (object[0].ptype == 5) {   /* open triangle */
    427     for (i = 0; i < object[0].Npts; i++) {
    428       if (!(finite(x[i]) && finite(y[i]))) continue;
    429       sx = x[i]*mxi + y[i]*mxj + bx;
    430       sy = x[i]*myi + y[i]*myj + by;
    431       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    432           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    433       {
    434         if (scaleColor) {
    435           if (!finite(z[i])) continue;
    436           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    437           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    438         }
    439         D = scaleSize ? dz*z[i] : ds;
    440         DrawLine (sx - D, sy - 0.58*D, sx + D, sy - 0.58*D);
    441         DrawLine (sx + D, sy - 0.58*D, sx,     sy + 1.15*D);
    442         DrawLine (sx,     sy + 1.15*D, sx - D, sy - 0.58*D);
    443       }
    444     }
    445   }
    446   if (object[0].ptype == 15) {  /* upside-down open triangle */
    447     for (i = 0; i < object[0].Npts; i++) {
    448       if (!(finite(x[i]) && finite(y[i]))) continue;
    449       sx = x[i]*mxi + y[i]*mxj + bx;
    450       sy = x[i]*myi + y[i]*myj + by;
    451       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    452           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    453       {
    454         if (scaleColor) {
    455           if (!finite(z[i])) continue;
    456           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    457           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    458         }
    459         D = scaleSize ? dz*z[i] : ds;
    460         DrawLine (sx - D, sy + 0.58*D, sx + D, sy + 0.58*D);
    461         DrawLine (sx + D, sy + 0.58*D, sx,     sy - 1.15*D);
    462         DrawLine (sx,     sy - 1.15*D, sx - D, sy + 0.58*D);
    463       }
    464     }
    465   }
    466   if (object[0].ptype == 6) {   /* Y */
    467     for (i = 0; i < object[0].Npts; i++) {
    468       if (!(finite(x[i]) && finite(y[i]))) continue;
    469       sx = x[i]*mxi + y[i]*mxj + bx;
    470       sy = x[i]*myi + y[i]*myj + by;
    471       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    472           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    473       {
    474         if (scaleColor) {
    475           if (!finite(z[i])) continue;
    476           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    477           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    478         }
    479         D = scaleSize ? dz*z[i] : ds;
    480         DrawLine (sx, sy, sx - D, sy + 0.58*D);
    481         DrawLine (sx, sy, sx + D, sy + 0.58*D);
    482         DrawLine (sx, sy, sx,          sy - 1.15*D);
    483       }
    484     }
    485   }
    486   if (object[0].ptype == 16) {  /* Y */
    487     for (i = 0; i < object[0].Npts; i++) {
    488       if (!(finite(x[i]) && finite(y[i]))) continue;
    489       sx = x[i]*mxi + y[i]*mxj + bx;
    490       sy = x[i]*myi + y[i]*myj + by;
    491       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    492           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    493       {
    494         if (scaleColor) {
    495           if (!finite(z[i])) continue;
    496           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    497           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    498         }
    499         D = scaleSize ? dz*z[i] : ds;
    500         DrawLine (sx, sy, sx - D, sy - 0.58*D);
    501         DrawLine (sx, sy, sx + D, sy - 0.58*D);
    502         DrawLine (sx, sy, sx,     sy + 1.15*D);
    503       }
    504     }
    505   }
    506   if (object[0].ptype == 7) {   /* 0 */
    507     for (i = 0; i < object[0].Npts; i++) {
    508       if (!(finite(x[i]) && finite(y[i]))) continue;
    509       sx = x[i]*mxi + y[i]*mxj + bx;
    510       sy = x[i]*myi + y[i]*myj + by;
    511       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    512           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    513       {
    514         if (scaleColor) {
    515           if (!finite(z[i])) continue;
    516           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    517           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    518         }
    519         D = scaleSize ? dz*z[i] : ds;
    520         DrawCircle (sx, sy, D);
    521       }
    522     }
    523   }
    524   if (object[0].ptype == 8) {   /* pentagon */
    525     for (i = 0; i < object[0].Npts; i++) {
    526       if (!(finite(x[i]) && finite(y[i]))) continue;
    527       sx = x[i]*mxi + y[i]*mxj + bx;
    528       sy = x[i]*myi + y[i]*myj + by;
    529       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    530           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    531       {
    532         if (scaleColor) {
    533           if (!finite(z[i])) continue;
    534           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    535           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    536         }
    537         D = scaleSize ? dz*z[i] : ds;
    538         DrawLine (sx + 0.00*D, sy + 1.00*D, sx + 0.95*D, sy + 0.31*D);
    539         DrawLine (sx + 0.95*D, sy + 0.31*D, sx + 0.58*D, sy - 0.81*D);
    540         DrawLine (sx + 0.58*D, sy - 0.81*D, sx - 0.58*D, sy - 0.81*D);
    541         DrawLine (sx - 0.58*D, sy - 0.81*D, sx - 0.95*D, sy + 0.31*D);
    542         DrawLine (sx - 0.95*D, sy + 0.31*D, sx + 0.00*D, sy + 1.00*D);
    543       }
    544     }
    545   }
    546   if (object[0].ptype == 9) {   /* hexagon */
    547     for (i = 0; i < object[0].Npts; i++) {
    548       if (!(finite(x[i]) && finite(y[i]))) continue;
    549       sx = x[i]*mxi + y[i]*mxj + bx;
    550       sy = x[i]*myi + y[i]*myj + by;
    551       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    552           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    553       {
    554         if (scaleColor) {
    555           if (!finite(z[i])) continue;
    556           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    557           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    558         }
    559         D = scaleSize ? dz*z[i] : ds;
    560         DrawLine (sx -      D, sy,               sx - 0.50*D, sy + 0.87*D);
    561         DrawLine (sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D);
    562         DrawLine (sx + 0.50*D, sy + 0.87*D, sx +      D, sy);
    563 
    564         DrawLine (sx +      D, sy,               sx + 0.50*D, sy - 0.87*D);
    565         DrawLine (sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D);
    566         DrawLine (sx - 0.50*D, sy - 0.87*D, sx -      D, sy);
    567       }
    568     }
    569   }
    570   if (object[0].ptype == 10) {  /* 0 */
    571     for (i = 0; i < object[0].Npts; i++) {
    572       if (!(finite(x[i]) && finite(y[i]))) continue;
    573       sx = x[i]*mxi + y[i]*mxj + bx;
    574       sy = x[i]*myi + y[i]*myj + by;
    575       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    576           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    577       {
    578         if (scaleColor) {
    579           if (!finite(z[i])) continue;
    580           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    581           fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
    582         }
    583         D = scaleSize ? dz*z[i] : ds;
    584         FillCircle (sx, sy, D);
    585       }
    586     }
    587   }
    588   if (object[0].ptype == 100) { /* connect a pair of points */
    589     double X0 = graph[0].axis[0].fx;
    590     double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
    591     double Y0 = graph[0].axis[1].fy;
    592     double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    593 
    594     for (i = 0; i + 1 < object[0].Npts; i+=2) {
    595       if (!(finite(x[i]) && finite(y[i]))) continue;
    596       sx1 = x[i]*mxi + y[i]*mxj + bx;
    597       sy1 = x[i]*myi + y[i]*myj + by;
    598       sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    599       sy2 = x[i+1]*myi + y[i+1]*myj + by;
    600       ClipLinePS (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1, f);
    601     }
    602   }
    603 
     593    case KAPA_POINT_BOX_SOLID:  /* filled box */
     594    default:
     595      for (i = 0; i < object[0].Npts; i++) {
     596        if (!(finite(x[i]) && finite(y[i]))) continue;
     597        sx = x[i]*mxi + y[i]*mxj + bx;
     598        sy = x[i]*myi + y[i]*myj + by;
     599        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     600            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     601          if (scaleColor) {
     602            if (!finite(z[i])) continue;
     603            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     604            fprintf (f, "%4.2f %4.2f %4.2f setrgbcolor\n", pixel1[pixel], pixel2[pixel], pixel3[pixel]);
     605          }
     606          D = scaleSize ? dz*z[i] : ds;
     607          FillRectangle (sx, sy, 2*D, 2*D);
     608        }
     609      }
     610      break;
     611  }
    604612  free (pixel1);
    605613  free (pixel2);
  • trunk/Ohana/src/kapa2/src/bDrawFrame.c

    r38986 r39926  
    1111
    1212  // don't need graphic, unlink DrawFrame
     13
     14  P = 0.5 * (1 + 0.25*graph[0].axis[0].lweight) * (hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy) + hypot (graph[0].axis[0].dfx, graph[0].axis[0].dfy));
    1315
    1416  /* each axis is drawn independently */
     
    2830    dfx = graph[0].axis[i].dfx + 2*dx;
    2931    dfy = graph[0].axis[i].dfy + 2*dy;
    30     P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    31     P *= (1 + 0.25*lweight);
     32
     33    // P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
     34    // P *= (1 + 0.25*lweight);
    3235
    3336    bDrawSetStyle (buffer, color, lweight, 0);
  • trunk/Ohana/src/kapa2/src/bDrawObjects.c

    r38153 r39926  
    1818 
    1919  int i;
    20   int type;
    21   int weight;
    22   bDrawColor color;
    23   bDrawColor black;
    24  
     20 
     21  // the functions below use this global value
    2522  graphic = GetGraphic();
    2623
    27   black = KapaColorByName ("black");
     24  // this function calls all of the supporting bDraw... functions below
    2825  for (i = 0; i < graph[0].Nobjects; i++) {
    29 
    30     weight = MAX (0, MIN (10, graph[0].objects[i].lweight));
    31     type = graph[0].objects[i].ltype;   
    32     color = graph[0].objects[i].color;
    33     bDrawSetStyle (buffer, color, weight, type);
    34 
    35     switch (graph[0].objects[i].style) {
    36       case CONNECT:
    37         bDrawConnect (buffer, graph, &graph[0].objects[i]);
    38         break;
    39       case HISTOGRAM:
    40         bDrawHistogram (buffer, graph, &graph[0].objects[i]);
    41         break;
    42       case POINTS:
    43         bDrawPoints (buffer, graph, &graph[0].objects[i]);
    44         break;
    45     }
    46 
    47     if (graph[0].objects[i].etype & 0x01) {
    48       bDrawYErrors (buffer, graph, &graph[0].objects[i]);
    49     }
    50     if (graph[0].objects[i].etype & 0x02) {
    51       bDrawXErrors (buffer, graph, &graph[0].objects[i]);
    52     }
    53   }
     26    bDrawObjectsN (buffer, graph, &graph[0].objects[i]);
     27  }
     28  bDrawColor black = KapaColorByName ("black");
    5429  bDrawSetStyle (buffer, black, 0, 0);
     30  return (TRUE);
     31}
     32
     33int bDrawObjectsN (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
     34 
     35  int weight = MAX (0, MIN (10, object->lweight));
     36  bDrawSetStyle (buffer, object->color, weight, object->ltype);
     37 
     38  switch (object->style) {
     39    case KAPA_PLOT_CONNECT:
     40      bDrawConnect (buffer, graph, object);
     41      break;
     42    case KAPA_PLOT_HISTOGRAM:
     43      bDrawHistogram (buffer, graph, object);
     44      break;
     45    case KAPA_PLOT_POINTS:
     46    default:
     47      bDrawPoints (buffer, graph, object);
     48      break;
     49  }
     50
     51  if (object->etype & 0x01) {
     52    bDrawYErrors (buffer, graph, object);
     53  }
     54  if (object->etype & 0x02) {
     55    bDrawXErrors (buffer, graph, object);
     56  }
     57
    5558  return (TRUE);
    5659}
     
    298301  x = object[0].x; y = object[0].y; z = object[0].z;
    299302
    300   if (object[0].ptype == 0) {   /* filled box */
    301     for (i = 0; i < object[0].Npts; i++) {
    302       if (!(finite(x[i]) && finite(y[i]))) continue;
    303       sx = x[i]*mxi + y[i]*mxj + bx;
    304       sy = x[i]*myi + y[i]*myj + by;
    305       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    306           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    307       {
    308         if (scaleColor) {
    309           if (!finite(z[i])) continue;
    310           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    311           buffer->bColor_R = pixel1[pixel];
    312           buffer->bColor_G = pixel2[pixel];
    313           buffer->bColor_B = pixel3[pixel];
    314         }
    315         D = scaleSize ? dz*z[i] : ds;
    316         FillRectangle (buffer, sx, sy, 2*D, 2*D);
    317         // plot range saturated by bDrawRectFill
    318       }
     303  switch (object[0].ptype) {
     304    case KAPA_POINT_BOX_OPEN:   /* open box */
     305      for (i = 0; i < object[0].Npts; i++) {
     306        if (!(finite(x[i]) && finite(y[i]))) continue;
     307        sx = x[i]*mxi + y[i]*mxj + bx;
     308        sy = x[i]*myi + y[i]*myj + by;
     309        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     310            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     311          if (scaleColor) {
     312            if (!finite(z[i])) continue;
     313            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     314            buffer->bColor_R = pixel1[pixel];
     315            buffer->bColor_G = pixel2[pixel];
     316            buffer->bColor_B = pixel3[pixel];
     317          }
     318          D = scaleSize ? dz*z[i] : ds;
     319          DrawRectangle (buffer, sx, sy, 2*D, 2*D);
     320          // plot range saturated by bDrawRectOpen
     321        }
     322      }
     323      break;
     324    case KAPA_POINT_CROSS: /* cross */
     325      for (i = 0; i < object[0].Npts; i++) {
     326        if (!(finite(x[i]) && finite(y[i]))) continue;
     327        sx = x[i]*mxi + y[i]*mxj + bx;
     328        sy = x[i]*myi + y[i]*myj + by;
     329        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     330            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     331          if (scaleColor) {
     332            if (!finite(z[i])) continue;
     333            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     334            buffer->bColor_R = pixel1[pixel];
     335            buffer->bColor_G = pixel2[pixel];
     336            buffer->bColor_B = pixel3[pixel];
     337          }
     338          D = scaleSize ? dz*z[i] : ds;
     339          DrawLine (buffer, sx - D, sy, sx + D, sy);
     340          DrawLine (buffer, sx, sy - D, sx, sy + D);
     341          // out-of-range points skipped by bDrawPoint
     342        }
     343      }
     344      break;
     345    case KAPA_POINT_X:  /* x */
     346      for (i = 0; i < object[0].Npts; i++) {
     347        if (!(finite(x[i]) && finite(y[i]))) continue;
     348        sx = x[i]*mxi + y[i]*mxj + bx;
     349        sy = x[i]*myi + y[i]*myj + by;
     350        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     351            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     352          if (scaleColor) {
     353            if (!finite(z[i])) continue;
     354            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     355            buffer->bColor_R = pixel1[pixel];
     356            buffer->bColor_G = pixel2[pixel];
     357            buffer->bColor_B = pixel3[pixel];
     358          }
     359          D = scaleSize ? dz*z[i] : ds;
     360          DrawLine (buffer, sx + D, sy - D, sx - D, sy + D);
     361          DrawLine (buffer, sx - D, sy - D, sx + D, sy + D);
     362          // out-of-range points skipped by bDrawPoint
     363        }
     364      }
     365      break;
     366    case KAPA_POINT_TRIANGLE_SOLID:     /* filled triangle */
     367      for (i = 0; i < object[0].Npts; i++) {
     368        if (!(finite(x[i]) && finite(y[i]))) continue;
     369        sx = x[i]*mxi + y[i]*mxj + bx;
     370        sy = x[i]*myi + y[i]*myj + by;
     371        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     372            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     373          if (scaleColor) {
     374            if (!finite(z[i])) continue;
     375            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     376            buffer->bColor_R = pixel1[pixel];
     377            buffer->bColor_G = pixel2[pixel];
     378            buffer->bColor_B = pixel3[pixel];
     379          }
     380          D = scaleSize ? dz*z[i] : ds;
     381          // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
     382          FillTriangle (buffer, sx, sy + 0.58*D, D, -1.73*D);
     383          // out-of-range points skipped by bDrawPoint
     384        }
     385      }
     386      break;
     387    case KAPA_POINT_TRIANGLE_SOLID_DOWN:        /* open triangle */
     388      for (i = 0; i < object[0].Npts; i++) {
     389        if (!(finite(x[i]) && finite(y[i]))) continue;
     390        sx = x[i]*mxi + y[i]*mxj + bx;
     391        sy = x[i]*myi + y[i]*myj + by;
     392        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     393            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     394          if (scaleColor) {
     395            if (!finite(z[i])) continue;
     396            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     397            buffer->bColor_R = pixel1[pixel];
     398            buffer->bColor_G = pixel2[pixel];
     399            buffer->bColor_B = pixel3[pixel];
     400          }
     401          D = scaleSize ? dz*z[i] : ds;
     402          // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
     403          FillTriangle (buffer, sx, sy - 0.58*D, D, +1.73*D);
     404          // out-of-range points skipped by bDrawPoint
     405        }
     406      }
     407      break;
     408    case KAPA_POINT_TRIANGLE_OPEN:      /* open triangle */
     409      for (i = 0; i < object[0].Npts; i++) {
     410        if (!(finite(x[i]) && finite(y[i]))) continue;
     411        sx = x[i]*mxi + y[i]*mxj + bx;
     412        sy = x[i]*myi + y[i]*myj + by;
     413        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     414            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     415          if (scaleColor) {
     416            if (!finite(z[i])) continue;
     417            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     418            buffer->bColor_R = pixel1[pixel];
     419            buffer->bColor_G = pixel2[pixel];
     420            buffer->bColor_B = pixel3[pixel];
     421          }
     422          D = scaleSize ? dz*z[i] : ds;
     423          OpenTriangle (buffer, sx - D, sy + 0.58*D, sx + D, sy + 0.58*D, sx, sy - 1.15*D);
     424          // out-of-range points skipped by bDrawPoint
     425        }
     426      }
     427      break;
     428    case KAPA_POINT_TRIANGLE_OPEN_DOWN: /* upside-down open triangle */
     429      for (i = 0; i < object[0].Npts; i++) {
     430        if (!(finite(x[i]) && finite(y[i]))) continue;
     431        sx = x[i]*mxi + y[i]*mxj + bx;
     432        sy = x[i]*myi + y[i]*myj + by;
     433        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     434            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     435          if (scaleColor) {
     436            if (!finite(z[i])) continue;
     437            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     438            buffer->bColor_R = pixel1[pixel];
     439            buffer->bColor_G = pixel2[pixel];
     440            buffer->bColor_B = pixel3[pixel];
     441          }
     442          D = scaleSize ? dz*z[i] : ds;
     443          OpenTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
     444          // out-of-range points skipped by bDrawPoint
     445        }
     446      }
     447      break;
     448    case KAPA_POINT_Y:  /* Y */
     449      for (i = 0; i < object[0].Npts; i++) {
     450        if (!(finite(x[i]) && finite(y[i]))) continue;
     451        sx = x[i]*mxi + y[i]*mxj + bx;
     452        sy = x[i]*myi + y[i]*myj + by;
     453        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     454            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     455          if (scaleColor) {
     456            if (!finite(z[i])) continue;
     457            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     458            buffer->bColor_R = pixel1[pixel];
     459            buffer->bColor_G = pixel2[pixel];
     460            buffer->bColor_B = pixel3[pixel];
     461          }
     462          D = scaleSize ? dz*z[i] : ds;
     463          DrawLine (buffer, sx, sy, sx - D, sy - 0.58*D);
     464          DrawLine (buffer, sx, sy, sx + D, sy - 0.58*D);
     465          DrawLine (buffer, sx, sy, sx,     sy + 1.15*D);
     466          // out-of-range points skipped by bDrawPoint
     467        }
     468      }
     469      break;
     470    case KAPA_POINT_Y_DOWN:     /* upside-down Y */
     471      for (i = 0; i < object[0].Npts; i++) {
     472        if (!(finite(x[i]) && finite(y[i]))) continue;
     473        sx = x[i]*mxi + y[i]*mxj + bx;
     474        sy = x[i]*myi + y[i]*myj + by;
     475        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     476            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     477          if (scaleColor) {
     478            if (!finite(z[i])) continue;
     479            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     480            buffer->bColor_R = pixel1[pixel];
     481            buffer->bColor_G = pixel2[pixel];
     482            buffer->bColor_B = pixel3[pixel];
     483          }
     484          D = scaleSize ? dz*z[i] : ds;
     485          DrawLine (buffer, sx, sy, sx - D, sy + 0.58*D);
     486          DrawLine (buffer, sx, sy, sx + D, sy + 0.58*D);
     487          DrawLine (buffer, sx, sy, sx,     sy - 1.15*D);
     488          // out-of-range points skipped by bDrawPoint
     489        }
     490      }
     491      break;
     492    case KAPA_POINT_CIRCLE_OPEN: /* 0 */
     493      for (i = 0; i < object[0].Npts; i++) {
     494        if (!(finite(x[i]) && finite(y[i]))) continue;
     495        sx = x[i]*mxi + y[i]*mxj + bx;
     496        sy = x[i]*myi + y[i]*myj + by;
     497        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     498            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     499          if (scaleColor) {
     500            if (!finite(z[i])) continue;
     501            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     502            buffer->bColor_R = pixel1[pixel];
     503            buffer->bColor_G = pixel2[pixel];
     504            buffer->bColor_B = pixel3[pixel];
     505          }
     506          D = scaleSize ? dz*z[i] : ds;
     507          DrawCircle (buffer, sx, sy, D);
     508          // out-of-range points skipped by bDrawPoint
     509        }
     510      }
     511      break;
     512    case KAPA_POINT_CIRCLE_SOLID: /* filled 0 */
     513      for (i = 0; i < object[0].Npts; i++) {
     514        if (!(finite(x[i]) && finite(y[i]))) continue;
     515        sx = x[i]*mxi + y[i]*mxj + bx;
     516        sy = x[i]*myi + y[i]*myj + by;
     517        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     518            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     519          if (scaleColor) {
     520            if (!finite(z[i])) continue;
     521            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     522            buffer->bColor_R = pixel1[pixel];
     523            buffer->bColor_G = pixel2[pixel];
     524            buffer->bColor_B = pixel3[pixel];
     525          }
     526          D = scaleSize ? dz*z[i] : ds;
     527          FillCircle (buffer, sx, sy, D);
     528          // out-of-range points skipped by bDrawLineHorizontal
     529        }
     530      }
     531      break;
     532    case KAPA_POINT_PENTAGON:   /* pentagon */
     533      for (i = 0; i < object[0].Npts; i++) {
     534        if (!(finite(x[i]) && finite(y[i]))) continue;
     535        sx = x[i]*mxi + y[i]*mxj + bx;
     536        sy = x[i]*myi + y[i]*myj + by;
     537        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     538            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     539          if (scaleColor) {
     540            if (!finite(z[i])) continue;
     541            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     542            buffer->bColor_R = pixel1[pixel];
     543            buffer->bColor_G = pixel2[pixel];
     544            buffer->bColor_B = pixel3[pixel];
     545          }
     546          D = scaleSize ? dz*z[i] : ds;
     547          DrawLine (buffer, sx + 0.00*D, sy - 1.00*D, sx + 0.95*D, sy - 0.31*D);
     548          DrawLine (buffer, sx + 0.95*D, sy - 0.31*D, sx + 0.58*D, sy + 0.81*D);
     549          DrawLine (buffer, sx + 0.58*D, sy + 0.81*D, sx - 0.58*D, sy + 0.81*D);
     550          DrawLine (buffer, sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D);
     551          DrawLine (buffer, sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D);
     552          // out-of-range points skipped by bDrawPoint
     553        }
     554      }
     555      break;
     556    case KAPA_POINT_HEXAGON:    /* hexagon */
     557      for (i = 0; i < object[0].Npts; i++) {
     558        if (!(finite(x[i]) && finite(y[i]))) continue;
     559        sx = x[i]*mxi + y[i]*mxj + bx;
     560        sy = x[i]*myi + y[i]*myj + by;
     561        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     562            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     563          if (scaleColor) {
     564            if (!finite(z[i])) continue;
     565            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     566            buffer->bColor_R = pixel1[pixel];
     567            buffer->bColor_G = pixel2[pixel];
     568            buffer->bColor_B = pixel3[pixel];
     569          }
     570          D = scaleSize ? dz*z[i] : ds;
     571          DrawLine (buffer, sx -      D, sy,          sx - 0.50*D, sy + 0.87*D);
     572          DrawLine (buffer, sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D);
     573          DrawLine (buffer, sx + 0.50*D, sy + 0.87*D, sx +      D, sy);
     574          DrawLine (buffer, sx +      D, sy,          sx + 0.50*D, sy - 0.87*D);
     575          DrawLine (buffer, sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D);
     576          DrawLine (buffer, sx - 0.50*D, sy - 0.87*D, sx -      D, sy);
     577          // out-of-range points skipped by bDrawPoint
     578        }
     579      }
     580      break;
     581    case KAPA_POINT_PAIR_CONNECT: { /* connect pairs of points */
     582
     583      double X0 = graph[0].axis[0].fx;
     584      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     585      double Y0 = graph[0].axis[1].fy;
     586      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     587
     588      for (i = 0; i + 1 < object[0].Npts; i+=2) {
     589        if (!(finite(x[i]) && finite(y[i]))) continue;
     590        sx1 = x[i]*mxi + y[i]*mxj + bx;
     591        sy1 = x[i]*myi + y[i]*myj + by;
     592        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
     593        sy2 = x[i+1]*myi + y[i+1]*myj + by;
     594        bDrawClipLine (buffer, sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
     595      }
     596      break;
    319597    }
    320   }
    321   if (object[0].ptype == 1) {   /* open box */
    322     for (i = 0; i < object[0].Npts; i++) {
    323       if (!(finite(x[i]) && finite(y[i]))) continue;
    324       sx = x[i]*mxi + y[i]*mxj + bx;
    325       sy = x[i]*myi + y[i]*myj + by;
    326       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    327           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    328       {
    329         if (scaleColor) {
    330           if (!finite(z[i])) continue;
    331           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    332           buffer->bColor_R = pixel1[pixel];
    333           buffer->bColor_G = pixel2[pixel];
    334           buffer->bColor_B = pixel3[pixel];
    335         }
    336         D = scaleSize ? dz*z[i] : ds;
    337         DrawRectangle (buffer, sx, sy, 2*D, 2*D);
    338         // plot range saturated by bDrawRectOpen
    339       }
    340     }
    341   }
    342   if (object[0].ptype == 2) { /* cross */
    343     for (i = 0; i < object[0].Npts; i++) {
    344       if (!(finite(x[i]) && finite(y[i]))) continue;
    345       sx = x[i]*mxi + y[i]*mxj + bx;
    346       sy = x[i]*myi + y[i]*myj + by;
    347       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    348           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    349       {
    350         if (scaleColor) {
    351           if (!finite(z[i])) continue;
    352           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    353           buffer->bColor_R = pixel1[pixel];
    354           buffer->bColor_G = pixel2[pixel];
    355           buffer->bColor_B = pixel3[pixel];
    356         }
    357         D = scaleSize ? dz*z[i] : ds;
    358         DrawLine (buffer, sx - D, sy, sx + D, sy);
    359         DrawLine (buffer, sx, sy - D, sx, sy + D);
    360         // out-of-range points skipped by bDrawPoint
    361       }
    362     }
    363   }
    364   if (object[0].ptype == 3) {   /* x */
    365     for (i = 0; i < object[0].Npts; i++) {
    366       if (!(finite(x[i]) && finite(y[i]))) continue;
    367       sx = x[i]*mxi + y[i]*mxj + bx;
    368       sy = x[i]*myi + y[i]*myj + by;
    369       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    370           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    371       {
    372         if (scaleColor) {
    373           if (!finite(z[i])) continue;
    374           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    375           buffer->bColor_R = pixel1[pixel];
    376           buffer->bColor_G = pixel2[pixel];
    377           buffer->bColor_B = pixel3[pixel];
    378         }
    379         D = scaleSize ? dz*z[i] : ds;
    380         DrawLine (buffer, sx + D, sy - D, sx - D, sy + D);
    381         DrawLine (buffer, sx - D, sy - D, sx + D, sy + D);
    382         // out-of-range points skipped by bDrawPoint
    383       }
    384     }
    385   }
    386   if (object[0].ptype == 4) {   /* filled triangle */
    387     for (i = 0; i < object[0].Npts; i++) {
    388       if (!(finite(x[i]) && finite(y[i]))) continue;
    389       sx = x[i]*mxi + y[i]*mxj + bx;
    390       sy = x[i]*myi + y[i]*myj + by;
    391       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    392           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    393       {
    394         if (scaleColor) {
    395           if (!finite(z[i])) continue;
    396           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    397           buffer->bColor_R = pixel1[pixel];
    398           buffer->bColor_G = pixel2[pixel];
    399           buffer->bColor_B = pixel3[pixel];
    400         }
    401         D = scaleSize ? dz*z[i] : ds;
    402         // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
    403         FillTriangle (buffer, sx, sy + 0.58*D, D, -1.73*D);
    404         // out-of-range points skipped by bDrawPoint
    405       }
    406     }
    407   }
    408   if (object[0].ptype == 14) {  /* filled triangle */
    409     for (i = 0; i < object[0].Npts; i++) {
    410       if (!(finite(x[i]) && finite(y[i]))) continue;
    411       sx = x[i]*mxi + y[i]*mxj + bx;
    412       sy = x[i]*myi + y[i]*myj + by;
    413       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    414           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    415       {
    416         if (scaleColor) {
    417           if (!finite(z[i])) continue;
    418           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    419           buffer->bColor_R = pixel1[pixel];
    420           buffer->bColor_G = pixel2[pixel];
    421           buffer->bColor_B = pixel3[pixel];
    422         }
    423         D = scaleSize ? dz*z[i] : ds;
    424         // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
    425         FillTriangle (buffer, sx, sy - 0.58*D, D, +1.73*D);
    426         // out-of-range points skipped by bDrawPoint
    427       }
    428     }
    429   }
    430   if (object[0].ptype == 5) {   /* open triangle */
    431     for (i = 0; i < object[0].Npts; i++) {
    432       if (!(finite(x[i]) && finite(y[i]))) continue;
    433       sx = x[i]*mxi + y[i]*mxj + bx;
    434       sy = x[i]*myi + y[i]*myj + by;
    435       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    436           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    437       {
    438         if (scaleColor) {
    439           if (!finite(z[i])) continue;
    440           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    441           buffer->bColor_R = pixel1[pixel];
    442           buffer->bColor_G = pixel2[pixel];
    443           buffer->bColor_B = pixel3[pixel];
    444         }
    445         D = scaleSize ? dz*z[i] : ds;
    446         OpenTriangle (buffer, sx - D, sy + 0.58*D, sx + D, sy + 0.58*D, sx, sy - 1.15*D);
    447         // out-of-range points skipped by bDrawPoint
    448       }
    449     }
    450   }
    451   if (object[0].ptype == 15) {  /* open triangle */
    452     for (i = 0; i < object[0].Npts; i++) {
    453       if (!(finite(x[i]) && finite(y[i]))) continue;
    454       sx = x[i]*mxi + y[i]*mxj + bx;
    455       sy = x[i]*myi + y[i]*myj + by;
    456       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    457           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    458       {
    459         if (scaleColor) {
    460           if (!finite(z[i])) continue;
    461           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    462           buffer->bColor_R = pixel1[pixel];
    463           buffer->bColor_G = pixel2[pixel];
    464           buffer->bColor_B = pixel3[pixel];
    465         }
    466         D = scaleSize ? dz*z[i] : ds;
    467         OpenTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
    468         // out-of-range points skipped by bDrawPoint
    469       }
    470     }
    471   }
    472   if (object[0].ptype == 6) {   /* Y */
    473     for (i = 0; i < object[0].Npts; i++) {
    474       if (!(finite(x[i]) && finite(y[i]))) continue;
    475       sx = x[i]*mxi + y[i]*mxj + bx;
    476       sy = x[i]*myi + y[i]*myj + by;
    477       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    478           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    479       {
    480         if (scaleColor) {
    481           if (!finite(z[i])) continue;
    482           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    483           buffer->bColor_R = pixel1[pixel];
    484           buffer->bColor_G = pixel2[pixel];
    485           buffer->bColor_B = pixel3[pixel];
    486         }
    487         D = scaleSize ? dz*z[i] : ds;
    488         DrawLine (buffer, sx, sy, sx - D, sy - 0.58*D);
    489         DrawLine (buffer, sx, sy, sx + D, sy - 0.58*D);
    490         DrawLine (buffer, sx, sy, sx,     sy + 1.15*D);
    491         // out-of-range points skipped by bDrawPoint
    492       }
    493     }
    494   }
    495   if (object[0].ptype == 16) {  /* Y */
    496     for (i = 0; i < object[0].Npts; i++) {
    497       if (!(finite(x[i]) && finite(y[i]))) continue;
    498       sx = x[i]*mxi + y[i]*mxj + bx;
    499       sy = x[i]*myi + y[i]*myj + by;
    500       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    501           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    502       {
    503         if (scaleColor) {
    504           if (!finite(z[i])) continue;
    505           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    506           buffer->bColor_R = pixel1[pixel];
    507           buffer->bColor_G = pixel2[pixel];
    508           buffer->bColor_B = pixel3[pixel];
    509         }
    510         D = scaleSize ? dz*z[i] : ds;
    511         DrawLine (buffer, sx, sy, sx - D, sy + 0.58*D);
    512         DrawLine (buffer, sx, sy, sx + D, sy + 0.58*D);
    513         DrawLine (buffer, sx, sy, sx,     sy - 1.15*D);
    514         // out-of-range points skipped by bDrawPoint
    515       }
    516     }
    517   }
    518   if (object[0].ptype == 7) {   /* 0 */
    519     for (i = 0; i < object[0].Npts; i++) {
    520       if (!(finite(x[i]) && finite(y[i]))) continue;
    521       sx = x[i]*mxi + y[i]*mxj + bx;
    522       sy = x[i]*myi + y[i]*myj + by;
    523       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    524           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    525       {
    526         if (scaleColor) {
    527           if (!finite(z[i])) continue;
    528           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    529           buffer->bColor_R = pixel1[pixel];
    530           buffer->bColor_G = pixel2[pixel];
    531           buffer->bColor_B = pixel3[pixel];
    532         }
    533         D = scaleSize ? dz*z[i] : ds;
    534         DrawCircle (buffer, sx, sy, D);
    535         // out-of-range points skipped by bDrawPoint
    536       }
    537     }
    538   }
    539   if (object[0].ptype == 8) {   /* pentagon */
    540     for (i = 0; i < object[0].Npts; i++) {
    541       if (!(finite(x[i]) && finite(y[i]))) continue;
    542       sx = x[i]*mxi + y[i]*mxj + bx;
    543       sy = x[i]*myi + y[i]*myj + by;
    544       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    545           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    546       {
    547         if (scaleColor) {
    548           if (!finite(z[i])) continue;
    549           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    550           buffer->bColor_R = pixel1[pixel];
    551           buffer->bColor_G = pixel2[pixel];
    552           buffer->bColor_B = pixel3[pixel];
    553         }
    554         D = scaleSize ? dz*z[i] : ds;
    555         DrawLine (buffer, sx + 0.00*D, sy - 1.00*D, sx + 0.95*D, sy - 0.31*D);
    556         DrawLine (buffer, sx + 0.95*D, sy - 0.31*D, sx + 0.58*D, sy + 0.81*D);
    557         DrawLine (buffer, sx + 0.58*D, sy + 0.81*D, sx - 0.58*D, sy + 0.81*D);
    558         DrawLine (buffer, sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D);
    559         DrawLine (buffer, sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D);
    560         // out-of-range points skipped by bDrawPoint
    561       }
    562     }
    563   }
    564   if (object[0].ptype == 9) {   /* hexagon */
    565     for (i = 0; i < object[0].Npts; i++) {
    566       if (!(finite(x[i]) && finite(y[i]))) continue;
    567       sx = x[i]*mxi + y[i]*mxj + bx;
    568       sy = x[i]*myi + y[i]*myj + by;
    569       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    570           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    571       {
    572         if (scaleColor) {
    573           if (!finite(z[i])) continue;
    574           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    575           buffer->bColor_R = pixel1[pixel];
    576           buffer->bColor_G = pixel2[pixel];
    577           buffer->bColor_B = pixel3[pixel];
    578         }
    579         D = scaleSize ? dz*z[i] : ds;
    580         DrawLine (buffer, sx -      D, sy,          sx - 0.50*D, sy + 0.87*D);
    581         DrawLine (buffer, sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D);
    582         DrawLine (buffer, sx + 0.50*D, sy + 0.87*D, sx +      D, sy);
    583         DrawLine (buffer, sx +      D, sy,          sx + 0.50*D, sy - 0.87*D);
    584         DrawLine (buffer, sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D);
    585         DrawLine (buffer, sx - 0.50*D, sy - 0.87*D, sx -      D, sy);
    586         // out-of-range points skipped by bDrawPoint
    587       }
    588     }
    589   }
    590   if (object[0].ptype == 10) {  /* filled circle */
    591     for (i = 0; i < object[0].Npts; i++) {
    592       if (!(finite(x[i]) && finite(y[i]))) continue;
    593       sx = x[i]*mxi + y[i]*mxj + bx;
    594       sy = x[i]*myi + y[i]*myj + by;
    595       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    596           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    597       {
    598         if (scaleColor) {
    599           if (!finite(z[i])) continue;
    600           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    601           buffer->bColor_R = pixel1[pixel];
    602           buffer->bColor_G = pixel2[pixel];
    603           buffer->bColor_B = pixel3[pixel];
    604         }
    605         D = scaleSize ? dz*z[i] : ds;
    606         FillCircle (buffer, sx, sy, D);
    607         // out-of-range points skipped by bDrawLineHorizontal
    608       }
    609     }
    610   }
    611   if (object[0].ptype == 12) {  /* filled triangle (down) */
    612     for (i = 0; i < object[0].Npts; i++) {
    613       if (!(finite(x[i]) && finite(y[i]))) continue;
    614       sx = x[i]*mxi + y[i]*mxj + bx;
    615       sy = x[i]*myi + y[i]*myj + by;
    616       if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
    617           (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy))
    618       {
    619         if (scaleColor) {
    620           if (!finite(z[i])) continue;
    621           int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
    622           buffer->bColor_R = pixel1[pixel];
    623           buffer->bColor_G = pixel2[pixel];
    624           buffer->bColor_B = pixel3[pixel];
    625         }
    626         D = scaleSize ? dz*z[i] : ds;
    627         // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D);
    628         FillTriangle (buffer, sx, sy + 0.58*D, D, 1.73*D);
    629         // out-of-range points skipped by bDrawPoint
    630       }
    631     }
    632   }
    633   if (object[0].ptype == 100) { /* connect a pair of points */
    634 
    635     double X0 = graph[0].axis[0].fx;
    636     double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
    637     double Y0 = graph[0].axis[1].fy;
    638     double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    639 
    640     for (i = 0; i + 1 < object[0].Npts; i+=2) {
    641       if (!(finite(x[i]) && finite(y[i]))) continue;
    642       sx1 = x[i]*mxi + y[i]*mxj + bx;
    643       sy1 = x[i]*myi + y[i]*myj + by;
    644       sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    645       sy2 = x[i+1]*myi + y[i+1]*myj + by;
    646       bDrawClipLine (buffer, sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
    647     }
    648   }
    649 
     598    case KAPA_POINT_BOX_SOLID:  /* filled box */
     599      for (i = 0; i < object[0].Npts; i++) {
     600        if (!(finite(x[i]) && finite(y[i]))) continue;
     601        sx = x[i]*mxi + y[i]*mxj + bx;
     602        sy = x[i]*myi + y[i]*myj + by;
     603        if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) &&
     604            (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) {
     605          if (scaleColor) {
     606            if (!finite(z[i])) continue;
     607            int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     608            buffer->bColor_R = pixel1[pixel];
     609            buffer->bColor_G = pixel2[pixel];
     610            buffer->bColor_B = pixel3[pixel];
     611          }
     612          D = scaleSize ? dz*z[i] : ds;
     613          FillRectangle (buffer, sx, sy, 2*D, 2*D);
     614          // plot range saturated by bDrawRectFill
     615        }
     616      }
     617      break;
     618  }
    650619  free (pixel1);
    651620  free (pixel2);
  • trunk/Ohana/src/libdvo/include/dvo.h

    r39670 r39926  
    114114/* Measure.flags values -- these values are 32 bit (as of PS1_V1) */
    115115typedef enum {
    116   ID_MEAS_NOCAL          = 0x00000001,  // detection ignored for this analysis (photcode, time range) -- internal only
    117   ID_MEAS_POOR_PHOTOM    = 0x00000002,  // detection is photometry outlier                                               
    118   ID_MEAS_SKIP_PHOTOM    = 0x00000004,  // detection was ignored for photometry measurement                               
    119   ID_MEAS_AREA           = 0x00000008,  // detection near image edge                                                 
    120   ID_MEAS_POOR_ASTROM    = 0x00000010,  // detection is astrometry outlier                                               
    121   ID_MEAS_SKIP_ASTROM    = 0x00000020,  // detection was ignored for astrometry measurement                               
    122   ID_MEAS_USED_OBJ       = 0x00000040,  // detection was used during update objects 
    123   ID_MEAS_USED_CHIP      = 0x00000080,  // detection was used during update chips (XXX this probably does not make it into the db)
    124   ID_MEAS_BLEND_MEAS     = 0x00000100,  // detection is within radius of multiple objects
    125   ID_MEAS_BLEND_OBJ      = 0x00000200,  // multiple detections within radius of object
    126   ID_MEAS_WARP_USED      = 0x00000400,  // measurement used to find mean warp photometry
    127   ID_MEAS_UNMASKED_ASTRO = 0x00000800,  // measurement was not masked in final astrometry fit
    128   ID_MEAS_BLEND_MEAS_X   = 0x00001000,  // detection is within radius of multiple objects across catalogs                   
    129   ID_MEAS_ARTIFACT       = 0x00002000,  // detection is thought to be non-astronomical                               
    130   ID_MEAS_SYNTH_MAG      = 0x00004000,  // magnitude is synthetic
    131   ID_MEAS_PHOTOM_UBERCAL = 0x00008000,  // externally-supplied zero point from ubercal analysis
    132   ID_MEAS_STACK_PRIMARY  = 0x00010000,  // this stack measurement is in the primary skycell
    133   ID_MEAS_STACK_PHOT_SRC = 0x00020000,  // this measurement supplied the stack photometry
    134   ID_MEAS_ICRF_QSO       = 0x00040000,  // this measurement is an ICRF reference position
    135   ID_MEAS_IMAGE_EPOCH    = 0x00080000,  // this measurement is registered to the image epoch (not tied to ref catalog epoch)
    136   ID_MEAS_PHOTOM_PSF     = 0x00100000,  // this measurement is used for the mean psf mag
    137   ID_MEAS_PHOTOM_APER    = 0x00200000,  // this measurement is used for the mean ap mag
    138   ID_MEAS_PHOTOM_KRON    = 0x00400000,  // this measurement is used for the mean kron mag
    139   ID_MEAS_MASKED_PSF     = 0x01000000,  // this measurement is masked based on IRLS weights for mean psf mag
    140   ID_MEAS_MASKED_APER    = 0x02000000,  // this measurement is masked based on IRLS weights for mean ap mag
    141   ID_MEAS_MASKED_KRON    = 0x04000000,  // this measurement is masked based on IRLS weights for mean kron mag
     116  ID_MEAS_NOCAL            = 0x00000001,  // detection ignored for this analysis (photcode, time range) -- internal only
     117  ID_MEAS_POOR_PHOTOM      = 0x00000002,  // detection is photometry outlier                                             
     118  ID_MEAS_SKIP_PHOTOM      = 0x00000004,  // detection was ignored for photometry measurement                             
     119  ID_MEAS_AREA             = 0x00000008,  // detection near image edge                                               
     120  ID_MEAS_POOR_ASTROM      = 0x00000010,  // detection is astrometry outlier                                             
     121  ID_MEAS_SKIP_ASTROM      = 0x00000020,  // detection was ignored for astrometry measurement                             
     122  ID_MEAS_USED_OBJ         = 0x00000040,  // detection was used during update objects 
     123  ID_MEAS_USED_CHIP        = 0x00000080,  // detection was used during update chips (XXX this probably does not make it into the db)
     124  ID_MEAS_BLEND_MEAS       = 0x00000100,  // detection is within radius of multiple objects
     125  ID_MEAS_BLEND_OBJ        = 0x00000200,  // multiple detections within radius of object
     126  ID_MEAS_WARP_USED        = 0x00000400,  // measurement used to find mean warp photometry
     127  ID_MEAS_UNMASKED_ASTRO   = 0x00000800,  // measurement was not masked in final astrometry fit
     128  ID_MEAS_BLEND_MEAS_X     = 0x00001000,  // detection is within radius of multiple objects across catalogs                 
     129  ID_MEAS_ARTIFACT         = 0x00002000,  // detection is thought to be non-astronomical                                     
     130  ID_MEAS_SYNTH_MAG        = 0x00004000,  // magnitude is synthetic
     131  ID_MEAS_PHOTOM_UBERCAL   = 0x00008000,  // externally-supplied zero point from ubercal analysis
     132  ID_MEAS_STACK_PRIMARY    = 0x00010000,  // this stack measurement is in the primary skycell
     133  ID_MEAS_STACK_PHOT_SRC   = 0x00020000,  // this measurement supplied the stack photometry
     134  ID_MEAS_ICRF_QSO         = 0x00040000,  // this measurement is an ICRF reference position
     135  ID_MEAS_IMAGE_EPOCH      = 0x00080000,  // this measurement is registered to the image epoch (not tied to ref catalog epoch)
     136  ID_MEAS_PHOTOM_PSF       = 0x00100000,  // this measurement is used for the mean psf mag
     137  ID_MEAS_PHOTOM_APER      = 0x00200000,  // this measurement is used for the mean ap mag
     138  ID_MEAS_PHOTOM_KRON      = 0x00400000,  // this measurement is used for the mean kron mag
     139  ID_MEAS_MASKED_PSF       = 0x01000000,  // this measurement is masked based on IRLS weights for mean psf mag
     140  ID_MEAS_MASKED_APER      = 0x02000000,  // this measurement is masked based on IRLS weights for mean ap mag
     141  ID_MEAS_MASKED_KRON      = 0x04000000,  // this measurement is masked based on IRLS weights for mean kron mag
     142  ID_MEAS_OBJECT_HAS_2MASS = 0x10000000,  // measurement comes from an object with 2mass data
     143  ID_MEAS_OBJECT_HAS_GAIA  = 0x20000000,  // measurement comes from an object with gaia data
     144  ID_MEAS_OBJECT_HAS_TYCHO = 0x40000000,  // measurement comes from an object with tycho data
    142145} DVOMeasureFlags;
    143146
     
    233236  ID_SECF_STACK_BESTDET = 0x00008000, // PS1 stack best measurement is a detection (not forced)
    234237  ID_SECF_STACK_PRIMDET = 0x00010000, // PS1 stack primary measurement is a detection (not forced)
     238
     239  ID_SECF_HAS_SDSS      = 0x00100000, // this photcode has SDSS photometry
     240  ID_SECF_HAS_HSC       = 0x00200000, // this photcode has HSC  photometry
     241  ID_SECF_HAS_CFH       = 0x00400000, // this photcode has CFH  photometry (mostly Megacam)
     242  ID_SECF_HAS_DES       = 0x00800000, // this photcode has DES  photometry
     243
    235244  ID_SECF_OBJ_EXT       = 0x01000000, // extended in this band
    236245
  • trunk/Ohana/src/libdvo/src/ImageMetadataSelection.c

    r37807 r39926  
    5959}
    6060
     61// note that this function is called by the dvo clients and uses the 'metadata' table
     62// generated by the dvo shell for the mosaic images only.
    6163Coords *MatchMosaicMetadata (unsigned int imageID) {
    6264
     
    7375  mosaic.crval2 = image[m].crval2;
    7476
     77  // note that image->theta is calculated based on pc1_1, pc1_2 when the metadata file is
     78  // generated
    7579  mosaic.pc1_1 =  cos(RAD_DEG*image[m].theta);
    7680  mosaic.pc1_2 =  sin(RAD_DEG*image[m].theta);
  • trunk/Ohana/src/libdvo/src/coordops.c

    r39608 r39926  
    8484
    8585  /** extra polynomial terms **/
     86  // for ZPN, these are used to modify the radial distance and not the X,Y coords
    8687  if ((coords[0].Npolyterms > 1) && (proj != PROJ_ZPN)) {
    8788    X2 = X*X;
     
    126127    if (proj == PROJ_WRP) {
    127128      if (!coords->mosaic) {
    128         myAbort ("missing mosaic element");
     129        // myAbort ("missing mosaic element");
     130        *ra  = L;
     131        *dec = M;
    129132        return (FALSE);
    130133      }
     
    157160          ctht = 0.0;
    158161        } else {
    159           T = DEG_RAD / R;
    160           stht =   T / sqrt ( 1.0 + T*T);
    161           ctht = 1.0 / sqrt ( 1.0 + T*T);
     162          // T = DEG_RAD / R; // T in 1/radians
     163          // stht =   T / sqrt ( 1.0 + T*T);
     164          // ctht = 1.0 / sqrt ( 1.0 + T*T);
     165
     166          T = RAD_DEG * R;
     167          stht = 1.0 / sqrt ( 1.0 + T*T);
     168          ctht =   T / sqrt ( 1.0 + T*T);
    162169        }
     170        break;
     171      case PROJ_SIN:
     172        // R = (180/pi) cos (theta)
     173        ctht = RAD_DEG * R;
     174        stht = sqrt (1 - ctht*ctht);
    163175        break;
    164176      case PROJ_STG:
     
    167179        ctht = sqrt (1 - stht*stht);
    168180        break;
    169       case PROJ_SIN:
    170         // R = (180/pi) cos (theta)
    171         ctht = RAD_DEG * R;
    172         stht = sqrt (1 - ctht*ctht);
    173         break;
    174181      case PROJ_ARC:
    175182        // R = 90 - theta (degrees)
     
    177184        stht = cos (RAD_DEG * R);
    178185        break;
    179 
    180       case PROJ_ZPN:
    181         // R = 90 - theta (degrees)
    182         // this is wrong because we are ignoring the distortion
    183         // XXX For now, just solve for terms up to n = 3
    184 
    185         // Ro = (pi/180)(90 - theta)
    186         // R = (180/pi)sum (P_i R^i)
    187 
    188         if (UKIRT_ONLY) {
    189           double Ro = RAD_DEG * R;
    190           double P1 = coords[0].polyterms[0][1];
    191           double P3 = coords[0].polyterms[0][3];
    192 
    193           // find the roots of f(gamma) = P1 gamma + P3 gamma^3 - Ro
    194           // starting guess for gamma is Ro / P1
    195           double gamma = Ro / P1;
    196 
    197           int i;
    198           for (i = 0; i < 5; i++) {
    199             double F = P1*gamma + P3*gamma*gamma*gamma - Ro;
    200             double dFdgamma = P1 + 3.0*P3*gamma*gamma;
    201 
    202             double gamma_new = gamma - F / dFdgamma;
    203             gamma = gamma_new;
    204           }
    205          
    206           double theta = 90.0 - gamma * DEG_RAD ;
    207           ctht = cos (RAD_DEG * theta);
    208           stht = sin (RAD_DEG * theta);
    209           break;
    210         }
    211186
    212187      case PROJ_ZEA:
     
    220195        ctht = sqrt (1 - stht*stht);
    221196        break;
     197
     198      case PROJ_ZPN:
     199
     200        // the forward projection is:
     201        // theta = atan2(stht, ctht)
     202        // gamma = (pi/2 - theta) : theta in radians
     203        // Ro = sum (P_i gamma^i)
     204        // R  = (180/pi) Ro
     205
     206        // given R, we need to find theta:
     207        // Ro = R * (pi / 180) = sum (P_i gamma^i)
     208        // solve sum (P_i gamma^i) - Ro = 0 using Newton-Raphson
     209
     210        // use Ro to get a guess for gamma and iterate
     211
     212        {
     213          double Ro = RAD_DEG * R;
     214         
     215          // find the roots of f(gamma) - Ro = 0
     216          // starting guess for gamma is (Ro - P0) / P1
     217          double gamma = (Ro - coords[0].polyterms[0][0]) / coords[0].polyterms[1][0];
     218         
     219          int iter;
     220          for (iter = 0; iter < 5; iter++) {
     221           
     222            double Rc = 0.0; // this will hold the ander
     223            double dR = 0.0;
     224            for (int i = coords[0].Npolyterms - 1; i > 1; i--) {
     225              double Pi = (i < 7) ? coords[0].polyterms[i][0] : coords[0].polyterms[i-7][1];
     226              Rc = (Rc + Pi)*gamma;
     227              dR = (dR + i*Pi)*gamma;
     228            }
     229            double P0 = coords[0].polyterms[0][0];
     230            double P1 = coords[0].polyterms[1][0];
     231            Rc = (Rc + P1)*gamma + P0;
     232            dR = (dR + P1);
     233
     234            double gamma_new = gamma - (Rc - Ro) / dR;
     235            gamma = gamma_new;
     236          }
     237         
     238          double theta = 90.0 - gamma * DEG_RAD ;
     239          ctht = cos (RAD_DEG * theta);
     240          stht = sin (RAD_DEG * theta);
     241          break;
     242        }
     243
    222244      default:
    223245        return (FALSE);
     
    354376
    355377      case PROJ_ZPN:
     378        // the forward projection is:
     379        // theta = atan2(stht, ctht)
     380        // gamma = (pi/2 - theta) : theta in radians
     381        // Ro = sum (P_i gamma^i)
     382        // R  = (180/pi) Ro
     383
    356384        // Ro = (pi/180)(90 - theta)
    357385        // R = (180/pi)sum (P_i R^i)
     386
     387        // is ZPN defined for Npolyterms = 0 or 1?
     388
    358389        ctht = hypot(sphi, cphi);
    359390        theta = atan2 (stht, ctht);
    360391
    361         double Rc;
    362         if (UKIRT_ONLY) {
    363           double P1 = coords[0].polyterms[0][1];
    364           double P3 = coords[0].polyterms[0][3];
    365           double gamma = RAD_DEG * (90 - DEG_RAD * theta);
    366           Rc = P1*gamma + P3*gamma*gamma*gamma;
    367         } else {
    368           double Ro = RAD_DEG * (90 - DEG_RAD * theta);
    369 
    370           // i = 0 .. Npolyterms - 1 (1 <= Npolyterms <= 21)
    371           i = coords[0].Npolyterms - 1;
    372           Rc = 0.0;
    373           while (i > 0) {
    374             if (i < 7) {
    375               Rc = (Rc + coords[0].polyterms[0][i])*Ro;
    376             } else {
    377               Rc = (Rc + coords[0].polyterms[1][i-7])*Ro;
    378             }
    379             i --;
    380           }
    381           Rc += coords[0].polyterms[0][i];
     392        double Ro;
     393        double gamma = M_PI_2 - theta;
     394
     395        // i = 0 .. Npolyterms - 1 (1 <= Npolyterms <= 21)
     396        Ro = 0.0;
     397        for (i = coords[0].Npolyterms - 1; i > 0; i --) {
     398          double Pi = (i < 7) ? coords[0].polyterms[i][0] : coords[0].polyterms[i-7][1];
     399          Ro = (Ro + Pi)*gamma;
    382400        }
    383         Rc = DEG_RAD * Rc;
     401        Ro += coords[0].polyterms[0][0];
     402
     403        Rc = DEG_RAD * Ro;
    384404
    385405        *L = (ctht == 0.0) ? 0.0 : +Rc * sphi / ctht ;
     
    609629enum {COORD_TYPE_NONE, COORD_TYPE_PC, COORD_TYPE_ROT, COORD_TYPE_CD, COORD_TYPE_LIN};
    610630
     631int GetRadialZPN (Coords *coords, Header *header);
     632
    611633int GetCoords (Coords *coords, Header *header) {
    612634 
    613   int i, status, status1, status2, itmp, Polynomial, Polyterm;
     635  int status, status1, status2, itmp, Polynomial, Polyterm;
    614636  double Lambda, rotate, rotate1, rotate2, scale;
    615637  double equinox;
     
    666688      status &= gfits_scan (header, "PC002002", "%f",  1, &coords[0].pc2_2);
    667689
     690      ctype = &coords[0].ctype[4];
     691
     692      // read the ZPN coeffients PV2_i (i = 0 < 14)
     693      // ZPN is inconsistent with the other Polynomial types
     694      if (!strcmp (ctype, "-ZPN")) {
     695        GetRadialZPN (coords, header);
     696        break;
     697      }
     698
    668699      /* set NPLYTERM based on header.  if NPLYTERM is missing, it should have a
    669700         value of 0, unless the projection type is one of PLY, DIS, WRP, in which
    670701         case it should be set to 3 */
    671       ctype = &coords[0].ctype[4];
    672702      Polynomial = !strcmp (ctype, "-PLY") || !strcmp (ctype, "-DIS") || !strcmp (ctype, "-WRP");
    673703      Polyterm = gfits_scan (header, "NPLYTERM", "%d", 1, &itmp);
     
    723753      coords[0].pc2_1 =  sin(rotate*RAD_DEG) / Lambda;
    724754      coords[0].pc2_2 =  cos(rotate*RAD_DEG);
     755
     756      // read the ZPN coeffients PV2_i (i = 0 < 14)
     757      if (!strcmp (&coords[0].ctype[4], "-ZPN")) GetRadialZPN (coords, header);
    725758      break;
    726759
     
    744777      coords[0].pc2_2 /= scale;
    745778
    746       if (!strcmp (&coords[0].ctype[4], "-ZPN")) {
    747         int found;
    748         for (i = 0; i < 14; i++) {
    749           char name[64];
    750           snprintf (name, 64, "PV2_%d", i);
    751           if (i < 7) {
    752             found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[0][i]);
    753           } else {
    754             found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[1][i-7]);
    755           }
    756           if ((i == 0) && !found) {
    757             coords[0].polyterms[0][0] = 0.0;
    758             continue;
    759           }
    760           if ((i == 1) && !found) {
    761             coords[0].polyterms[0][1] = 1.0;
    762             continue;
    763           }
    764           if (!found) {
    765             coords[0].Npolyterms = i;
    766             break;
    767           }
    768         }
    769       }
     779      // read the ZPN coeffients PV2_i (i = 0 < 14)
     780      if (!strcmp (&coords[0].ctype[4], "-ZPN")) GetRadialZPN (coords, header);
    770781      break;
    771782
     
    819830  }
    820831  return (status);
     832}
     833
     834int GetRadialZPN (Coords *coords, Header *header) {
     835
     836  // RA---ZPN can have up to 14 radial polynomial terms.  these are stored in
     837  // polyterms[0][0] - [6][0] for the first 7 and [0][1] - [6][1] for the rest
     838  // these terms are coeffients of a polynomial of the radial distances
     839
     840  // read the ZPN coeffients PV2_i (i = 0 < 14)
     841  int found;
     842  int Nmax = 0;
     843  for (int i = 0; i < 14; i++) {
     844    char name[64];
     845    snprintf (name, 64, "PV2_%d", i);
     846    if (i < 7) {
     847      coords[0].polyterms[i][0] = 0.0;
     848      found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[i][0]);
     849    } else {
     850      coords[0].polyterms[i-7][1] = 0.0;
     851      found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[i-7][1]);
     852    }
     853    // PV2_1 is implicit if not present
     854    if ((i == 1) && !found) {
     855      coords[0].polyterms[1][0] = 1.0;
     856      continue;
     857    }
     858    // set Npolyterms based on the largest coefficient found
     859    if (found) {
     860      Nmax = i;
     861    }
     862  }
     863  coords[0].Npolyterms = Nmax + 1;
     864  return TRUE;
    821865}
    822866
  • trunk/Ohana/src/libdvo/src/dbExtractMeasures.c

    r39670 r39926  
    427427      break;
    428428    case MEAS_TMEAN: /* OK */
     429      value.Flt = TimeValue (average[0].Tmean, TimeReference, TimeFormat);
     430      break;
     431    case MEAS_TRANGE: /* OK */
    429432      value.Flt = GetTimeRange (average[0].Trange, TimeFormat);
    430       break;
    431     case MEAS_TRANGE: /* OK */
    432       value.Flt = TimeValue (average[0].Trange, 0, TimeFormat);
    433433      break;
    434434    case MEAS_NMEAS: /* OK */
     
    461461      break;
    462462    case MEAS_RA_FIT_OFFSET: /* OK */
     463      // RA_epoch_fit = RA_mean + uR*(t - Tmean)/cos(dec) + plx*parR
     464      // note that this extraction ignores parallax
    463465      dT = (measure[0].t - average[0].Tmean) / (86400*365.25);
    464       dR = dvoOffsetR (measure, average);
    465       value.Flt = average[0].uR * dT + dR;
     466      dR = dvoOffsetR (measure, average); // RA_epoch - RA_mean (** NOT local linear distance **)
     467      value.Flt = dR*cos(RAD_DEG*measure[0].D) - average[0].uR * dT;
     468      // this is the local linear distance of the measurement from the fit
    466469      break;
    467470    case MEAS_DEC_FIT_OFFSET: /* OK */
    468471      dT = (measure[0].t - average[0].Tmean) / (86400*365.25);
    469472      dD = dvoOffsetD (measure, average);
    470       value.Flt = average[0].uD * dT + dD;
     473      value.Flt = dD - average[0].uD * dT;
    471474      break;
    472475    case MEAS_RA_OFFSET_ERR: /* OK */
  • trunk/Ohana/src/libdvo/src/galaxy_model.c

    r39588 r39926  
    2828    V_sol  =  11.18; // km/sec
    2929    W_sol  =   7.61; // km/sec
     30    return TRUE;
     31  }
     32  if (!strcmp(version, "TEST-CONSTANT")) {
     33    // use for testing
     34    A_oort = +47.40; // km/sec/kpc
     35    B_oort = -47.40; // km/sec/kpc
     36    U_sol  =   0.00; // km/sec
     37    V_sol  =   0.00; // km/sec
     38    W_sol  =   0.00; // km/sec
     39    return TRUE;
     40  }
     41  if (!strcmp(version, "TEST-ZERO")) {
     42    // use for testing
     43    A_oort =   0.00; // km/sec/kpc
     44    B_oort =   0.00; // km/sec/kpc
     45    U_sol  =   0.00; // km/sec
     46    V_sol  =   0.00; // km/sec
     47    W_sol  =   0.00; // km/sec
    3048    return TRUE;
    3149  }
  • trunk/Ohana/src/libfits/header/F_H_field.c

    r38986 r39926  
    9090      ptr = buf + 9; // start of following keyword
    9191      if (strncmp (field, ptr, Nfield)) continue;
     92      if (ptr[Nfield + 1] != '=') continue; // the strncmp above will match a longer string which matches the subset of field (e.g., FOO will match FOOBAR and FOO).  test for the following '=' sign
    9293      Nfound ++;
    9394      if (Nfound == N) return (ptr);
  • trunk/Ohana/src/libkapa/Makefile

    r39590 r39926  
    3434$(SRC)/KapaWindow.$(ARCH).o \
    3535$(SRC)/KapaColors.$(ARCH).o \
     36$(SRC)/KapaStyles.$(ARCH).o \
    3637$(SRC)/KapaOpen.$(ARCH).o
    3738
  • trunk/Ohana/src/libkapa/include/kapa.h

    r38986 r39926  
    2525typedef struct sockaddr_in KapaSockAddress;
    2626
    27 typedef struct {
    28   float *data1d;
    29   float **data2d;
    30   int Nx;
    31   int Ny;
    32 } KiiImage;
    33 
    34 typedef struct {
    35   float x;
    36   float y;
    37   float dx;
    38   float dy;
    39   float angle;
    40   int type;
    41 } KiiOverlayBase;
    42 
    43 typedef struct {
    44   float x;
    45   float y;
    46   float dx;
    47   float dy;
    48   float angle;
    49   int type;
    50   char *text;
    51 } KiiOverlay;
     27// retain historical numerical definitions:
     28typedef enum {
     29  KAPA_LINE_INVALID_MIN = -1,
     30  KAPA_LINE_SOLID       = 0,
     31  KAPA_LINE_DOT         = 1,
     32  KAPA_LINE_DASH_SHORT  = 2,
     33  KAPA_LINE_DASH_LONG   = 3,
     34  KAPA_LINE_DOT_DASH    = 4,
     35  KAPA_LINE_INVALID_MAX = 5,
     36} KapaLineType;
     37
     38// retain historical numerical definitions:
     39typedef enum {
     40  KAPA_PLOT_INVALID_MIN = -1,
     41  KAPA_PLOT_CONNECT     =  0,
     42  KAPA_PLOT_HISTOGRAM   =  1,
     43  KAPA_PLOT_POINTS      =  2,
     44  KAPA_PLOT_INVALID_MAX =  3,
     45} KapaPlotStyle;
     46
     47typedef enum {
     48  KAPA_POINT_INVALID_MIN         = -1,
     49  KAPA_POINT_BOX_SOLID           =  0,
     50  KAPA_POINT_BOX_OPEN            =  1,
     51  KAPA_POINT_CROSS               =  2, // OR PLUS
     52  KAPA_POINT_X                   =  3,
     53  KAPA_POINT_Y                   =  4,
     54  KAPA_POINT_TRIANGLE_SOLID      =  5,
     55  KAPA_POINT_TRIANGLE_OPEN       =  6,
     56  KAPA_POINT_CIRCLE_OPEN         =  7,
     57  KAPA_POINT_PENTAGON            =  8,
     58  KAPA_POINT_HEXAGON             =  9,
     59  KAPA_POINT_CIRCLE_SOLID        = 10,
     60  KAPA_POINT_TRIANGLE_SOLID_DOWN = 11,
     61  KAPA_POINT_TRIANGLE_OPEN_DOWN  = 12,
     62  KAPA_POINT_Y_DOWN              = 13,
     63  KAPA_POINT_INVALID_MAX         = 14,
     64  KAPA_POINT_PAIR_CONNECT        = 100, // change to a plot style?
     65} KapaPointStyle;
     66// note that PAIR_CONNECT was historically 100
     67
    5268
    5369typedef enum {
     
    7591  KAPA_PS_RAWPAGE
    7692} KapaPSmode;
     93
     94typedef struct {
     95  float *data1d;
     96  float **data2d;
     97  int Nx;
     98  int Ny;
     99} KiiImage;
     100
     101typedef struct {
     102  float x;
     103  float y;
     104  float dx;
     105  float dy;
     106  float angle;
     107  int type;
     108} KiiOverlayBase;
     109
     110typedef struct {
     111  float x;
     112  float y;
     113  float dx;
     114  float dy;
     115  float angle;
     116  int type;
     117  char *text;
     118} KiiOverlay;
    77119
    78120typedef struct {
     
    219261unsigned long *KapaX11colors (Display *display, Colormap colormap, unsigned long default_color, int *Ncolors);
    220262
     263/* KapaStyles.c */
     264KapaLineType KapaLineTypeFromString (char *string);
     265KapaPlotStyle KapaPlotStyleFromString (char *string);
     266KapaPointStyle KapaPointStyleFromString (char *string);
     267
    221268/* RotFont.c */
    222269void InitRotFonts PROTO((void));
  • trunk/Ohana/src/libkapa/src/KapaOpen.c

    r39457 r39926  
    66# define MY_PORT 2500
    77# define MY_PORT_MAX 2520
    8 # define MY_WAIT 100000
     8# define MY_WAIT 1000000
    99# define DEBUG 0
    1010
  • trunk/Ohana/src/libkapa/src/KapaWindow.c

    r39652 r39926  
    449449  return (TRUE);
    450450}
     451
  • trunk/Ohana/src/libkapa/src/bDrawFuncs.c

    r36488 r39926  
    222222  e = 0;
    223223  for (X = X1, N = 0; X <= X2; X++, N++) {
    224     if (buffer->bType == 1) { DashOn = (N % 10) < 5; }
    225     if (buffer->bType == 2) { DashOn = (N % 6) < 3; }
     224    if (buffer->bType == KAPA_LINE_DOT) {
     225      DashOn = (N % 5) == 0 || (N % 5) == 1;
     226    }
     227    if (buffer->bType == KAPA_LINE_DASH_SHORT) {
     228      DashOn = (N % 8) < 4;
     229    }
     230    if (buffer->bType == KAPA_LINE_DASH_LONG) {
     231      DashOn = (N % 16) < 8;
     232    }
     233    if (buffer->bType == KAPA_LINE_DOT_DASH) {
     234      DashOn = ((N % 12) < 2) || ((N % 12 >= 6) && (N % 12 < 10)) ;
     235    }
    226236    if (swapcoords) {
    227237      if (DashOn) bDrawPoint (buffer, Y,X);
  • trunk/Ohana/src/opihi/cmd.astro/csystem.c

    r39591 r39926  
    125125  opihi_flt *yptr = yvec[0].elements.Flt;
    126126
    127   opihi_flt *uxptr = uxvec ? xvec[0].elements.Flt : NULL;
    128   opihi_flt *uyptr = uyvec ? yvec[0].elements.Flt : NULL;
     127  opihi_flt *uxptr = uxvec ? uxvec[0].elements.Flt : NULL;
     128  opihi_flt *uyptr = uyvec ? uyvec[0].elements.Flt : NULL;
    129129
    130130  for (i = 0; i < xvec[0].Nelements; i++, xptr++, yptr++) {
  • trunk/Ohana/src/opihi/cmd.astro/fitplx_irls.c

    r39610 r39926  
    158158    // now that the mask has been updated, we need to recalculate mean epoch and positions
    159159    // XXX make this conditional on actually masking unmasked points above
    160     PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal);
    161     PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean);
     160    // PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal);
     161    // PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean);
    162162
    163163    PlxFitData sample;
     
    218218  // fprintf (stderr, "%f +/- %f | %f %f\n", fit.p, fit.dp, fit.uR, fit.uD);
    219219
    220 /*
    221   FILE *f = fopen ("test.pf.dat", "w");
     220  Vector *dRresPMP, *dDresPMP, *dRresPLX, *dDresPLX;
     221
     222  // save fit residuals (with only pm removed, and pm and plx removed)
     223  if ((dRresPMP = SelectVector ("dRresPMP", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dRresPMP");
     224  if ((dDresPMP = SelectVector ("dDresPMP", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPMP");
     225  if ((dRresPLX = SelectVector ("dRresPLX", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dRresPLX");
     226  if ((dDresPLX = SelectVector ("dDresPLX", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPLX");
     227   
     228  ResetVector (dRresPMP, OPIHI_FLT, Ntotal);
     229  ResetVector (dDresPMP, OPIHI_FLT, Ntotal);
     230  ResetVector (dRresPLX, OPIHI_FLT, Ntotal);
     231  ResetVector (dDresPLX, OPIHI_FLT, Ntotal);
     232 
    222233  for (i = 0; i < Ntotal; i++) {
    223     double Xf = fit.Ro + fit.uR*fitdata.t[i] + fit.p*fitdata.pX[i];
    224     double Yf = fit.Do + fit.uD*fitdata.t[i] + fit.p*fitdata.pY[i];
    225     fprintf (f, "%f : %f %f : %f %f : %f : %f %f : %f %f\n", T[i], R[i], D[i], Xf, Yf, fitdata.t[i], fitdata.X[i], fitdata.Y[i], fitdata.pX[i], fitdata.pY[i]);
    226   }
    227   fclose (f);
    228 */
     234   
     235    double x0, y0;
     236    RD_to_XY (&x0, &y0, R[i], D[i], &coords);
     237
     238    double pX0, pY0;
     239    ParFactor (&pX0, &pY0, R[i], D[i], T[i]);
     240
     241    double t0 = (T[i] - Tmean)/365.25;
     242
     243    double Xpmp = fit.Ro + fit.uR*t0 + fit.p*pX0;
     244    double Ypmp = fit.Do + fit.uD*t0 + fit.p*pY0;
     245    double Xplx = fit.Ro + fit.uR*t0;
     246    double Yplx = fit.Do + fit.uD*t0;
     247
     248    dRresPMP->elements.Flt[i] = x0 - Xpmp;
     249    dDresPMP->elements.Flt[i] = y0 - Ypmp;
     250    dRresPLX->elements.Flt[i] = x0 - Xplx;
     251    dDresPLX->elements.Flt[i] = y0 - Yplx;
     252  }
    229253
    230254  // fprintf (stderr, "Roff, Doff: %f, %f; dRo, dDo: %f, %f\n", fit.Ro, fit.Do, fit.dRo, fit.dDo);
  • trunk/Ohana/src/opihi/cmd.astro/spex1dgas.c

    r33662 r39926  
    108108  IDList = NULL;
    109109  XoList = NULL;
    110   {
    111     // init random numbers
    112     long A, B;
    113     A = time(NULL);
    114     for (B = 0; A == time(NULL); B++);
    115     srand48(B);
    116   }
    117110 
     111  // srand48() is called by startup.c
     112
    118113  if (argc != 11) goto usage;
    119114
  • trunk/Ohana/src/opihi/cmd.astro/spex2dgas.c

    r33662 r39926  
    120120  float XoMax, YoMax;
    121121
    122   {
    123     // init random numbers
    124     long A, B;
    125     A = time(NULL);
    126     for (B = 0; A == time(NULL); B++);
    127     srand48(B);
    128   }
    129  
     122  // srand48() is called by startup.c
     123
    130124  if (argc != 9) goto usage;
    131125
  • trunk/Ohana/src/opihi/cmd.astro/spexseq.c

    r39457 r39926  
    9090  int Nobject = 0;
    9191
    92   {
    93     // init random numbers
    94     long A, B;
    95     A = time(NULL);
    96     for (B = 0; A == time(NULL); B++);
    97     srand48(B);
    98   }
    99  
    10092  if (argc != 6) goto usage;
     93
     94  // srand48() is called by startup.c
    10195
    10296  // XXX enforce matching lengths on the three vectors
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r39638 r39926  
    124124$(SRC)/resize.$(ARCH).o         \
    125125$(SRC)/relocate.$(ARCH).o       \
     126$(SRC)/rndseed.$(ARCH).o                \
    126127$(SRC)/roll.$(ARCH).o           \
    127128$(SRC)/rotate.$(ARCH).o \
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r39638 r39926  
    113113int reindex          PROTO((int, char **));
    114114int relocate         PROTO((int, char **));
     115int rndseed          PROTO((int, char **));
    115116int roll             PROTO((int, char **));
    116117int rotate           PROTO((int, char **));
     
    293294  {1, "relocate",     relocate,         "set graphics/image window position"},
    294295  {1, "roll",         roll,             "roll image to new start point"},
     296  {1, "rndseed",      rndseed,          "set the pseudo-random seed"},
    295297  {1, "rotate",       rotate,           "rotate image"},
    296298  {1, "save",         save,             "save an SAOimage style image overlay"},
  • trunk/Ohana/src/opihi/cmd.data/match2d.c

    r36084 r39926  
    11# include "data.h"
    22
    3 int find_matches2d (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2);
     3int find_matches2d (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2, Vector *radiusMatch);
    44int find_matches2d_closest (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index);
     5
     6int find_matches2d_sphere (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2, Vector *radiusMatch);
     7int find_matches2d_sphere_closest (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index);
    58
    69// match2d (X1) (Y1) (X2) (Y2) (Radius) [-index1 (index1)] [-index2 (index2)] [-nomatch1 nomatch1] [-nomatch2 nomatch2]
     
    2326  }
    2427
     28  int SPHERE_DISTANCE = FALSE;
     29  if ((N = get_argument (argc, argv, "-sphere"))) {
     30    remove_argument (N, &argc, argv);
     31    SPHERE_DISTANCE = TRUE;
     32  }
     33  if ((N = get_argument (argc, argv, "-sky"))) {
     34    remove_argument (N, &argc, argv);
     35    SPHERE_DISTANCE = TRUE;
     36  }
     37
    2538  if ((N = get_argument (argc, argv, "-index1"))) {
    2639    remove_argument (N, &argc, argv);
     
    3750  } else {
    3851    if ((index2 = SelectVector ("index2", ANYVECTOR, TRUE)) == NULL) return (FALSE);   
     52  }
     53
     54 
     55  Vector *radiusMatch = NULL;
     56  if ((N = get_argument (argc, argv, "-radius"))) {
     57    if (CLOSEST) {
     58      gprint (GP_ERR, "error: -radius and -closest are currently incompatible\n");
     59      return (FALSE);
     60    }
     61    remove_argument (N, &argc, argv);
     62    if ((radiusMatch = SelectVector (argv[N], ANYVECTOR, TRUE)) == NULL) return (FALSE);   
     63    remove_argument (N, &argc, argv);
    3964  }
    4065
     
    84109  }
    85110
    86   if (CLOSEST) {
     111  if (SPHERE_DISTANCE) {
     112    if (CLOSEST) {
     113      find_matches2d_sphere_closest (X1vec, Y1vec, X2vec, Y2vec, Radius, index1);
     114      find_matches2d_sphere_closest (X2vec, Y2vec, X1vec, Y1vec, Radius, index2);
     115    } else {
     116      find_matches2d_sphere (X1vec, Y1vec, X2vec, Y2vec, Radius, index1, index2, radiusMatch);
     117    }
     118  } else {
     119    if (CLOSEST) {
    87120      find_matches2d_closest (X1vec, Y1vec, X2vec, Y2vec, Radius, index1);
    88121      find_matches2d_closest (X2vec, Y2vec, X1vec, Y1vec, Radius, index2);
    89   } else {
    90       find_matches2d (X1vec, Y1vec, X2vec, Y2vec, Radius, index1, index2);
    91   }
    92 
     122    } else {
     123      find_matches2d (X1vec, Y1vec, X2vec, Y2vec, Radius, index1, index2, radiusMatch);
     124    }
     125  }
    93126  return (TRUE);
    94127
     
    108141  gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n");
    109142
     143  gprint (GP_ERR, "if -sphere or -sky is supplied, (x1,y1) and (x2,y2) are treaded as (ra,dec) or (long,lat) pairs in degrees\n");
     144
     145  gprint (GP_ERR, "if -radius (vector) is supplied, the vector will be filled with the distance between the matched pairs\n");
     146  gprint (GP_ERR, "  not valid with -closest\n");
    110147  return FALSE;
    111148}
    112149
    113150// we are not defining a relative offset DX,DY for now
    114 int find_matches2d (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2) {
     151int find_matches2d (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2, Vector *radiusMatch) {
    115152 
    116153  off_t i, j, first_j, I, J, *N1, *N2, Nmatch, NMATCH, DMATCH;
     
    122159  ResetVector (index1, OPIHI_INT, NMATCH);
    123160  ResetVector (index2, OPIHI_INT, NMATCH);
     161  if (radiusMatch) ResetVector (radiusMatch, OPIHI_FLT, NMATCH);
    124162
    125163  ALLOCATE (N1, off_t, X1->Nelements);
     
    154192        index1->elements.Int[Nmatch] = I;
    155193        index2->elements.Int[Nmatch] = J;
     194        if (radiusMatch) radiusMatch->elements.Flt[Nmatch] = dR;
    156195
    157196        // XXX track matches 1 and 2 with internal vector, save new nomatch index vectors
     
    163202          REALLOCATE (index1->elements.Int, opihi_int, NMATCH);
    164203          REALLOCATE (index2->elements.Int, opihi_int, NMATCH);
     204          if (radiusMatch) { REALLOCATE (radiusMatch->elements.Flt, opihi_flt, NMATCH); }
    165205        }
    166206      }
     
    171211  index1->Nelements = Nmatch;
    172212  index2->Nelements = Nmatch;
     213  if (radiusMatch) radiusMatch->Nelements = Nmatch;
    173214
    174215  free (N1);
     
    246287  return (TRUE);
    247288}
     289
     290double gcdist (double r1, double d1, double r2, double d2) {
     291  double num,den;
     292  r1 *= RAD_DEG;
     293  d1 *= RAD_DEG;
     294  r2 *= RAD_DEG;
     295  d2 *= RAD_DEG;
     296
     297  num = sqrt(pow((cos(d2) * sin(r2 - r1)),2) +
     298             pow((cos(d1) * sin(d2) -
     299                  sin(d1) * cos(d2) * cos(r2 - r1)),2));
     300  den = (sin(d1) * sin(d2) + cos(d1) * cos(d2) * cos(r2 - r1));
     301  return(atan2(num,den) * (180 / M_PI));
     302}
     303
     304typedef struct {
     305  double sD;
     306  double cD;
     307  double sR;
     308  double cR;
     309} Match2D_PreCalc;
     310
     311double gcdist_PreCalc_v0 (Match2D_PreCalc *p1, Match2D_PreCalc *p2) {
     312  double num,den;
     313
     314  num = sqrt(pow((p2->cD * (p2->sR*p1->cR - p1->sR*p2->cR)),2) +
     315             pow((p1->cD * p2->sD -
     316                  p1->sD * p2->cD * (p2->cR*p1->cR + p2->sR*p1->sR)),2));
     317  den = (p1->sD * p2->sD + p1->cD * p2->cD * (p2->cR*p1->cR + p2->sR*p1->sR));
     318  return(atan2(num,den) * (180 / M_PI));
     319}
     320
     321// we are not defining a relative offset DX,DY for now
     322double gcdist_PreCalc (Match2D_PreCalc *p1, Match2D_PreCalc *p2) {
     323  double num,den;
     324
     325  // double Qd = p1->sD * p1->cD * p2->sD * p2->cD;
     326  // double Qr = p1->sR * p1->cR * p2->sR * p2->cR;
     327
     328  //  double Xa
     329  //    = SQ(p2->cD * p1->cR * p2->sR)
     330  //    + SQ(p2->cD * p1->sR * p2->cR) -
     331  //    - 2 * SQ(p2->cD) * Qr;
     332
     333  double cdR = (p2->cR*p1->cR + p2->sR*p1->sR);
     334
     335  double Xa = SQ(p2->cD * p2->sR * p1->cR - p2->cD * p1->sR * p2->cR);
     336  double Xb = SQ(p1->cD * p2->sD - p1->sD * p2->cD * cdR);
     337
     338  num = sqrt(Xa + Xb);
     339  den = (p1->sD * p2->sD + p1->cD * p2->cD * cdR);
     340  return(atan2(num,den) * (180 / M_PI));
     341}
     342
     343// we are not defining a relative offset DX,DY for now
     344int find_matches2d_sphere (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2, Vector *radiusMatch) {
     345 
     346  off_t i, j, first_j, I, J, *N1, *N2, Nmatch, NMATCH, DMATCH;
     347  double dY, dR;
     348
     349  NMATCH = MAX(MAX(0.05*X1->Nelements, 0.05*X2->Nelements), 1000);
     350  DMATCH = NMATCH;
     351
     352  ResetVector (index1, OPIHI_INT, NMATCH);
     353  ResetVector (index2, OPIHI_INT, NMATCH);
     354  if (radiusMatch) ResetVector (radiusMatch, OPIHI_FLT, NMATCH);
     355
     356  ALLOCATE (N1, off_t, X1->Nelements);
     357  ALLOCATE (N2, off_t, X2->Nelements);
     358
     359  ALLOCATE_PTR (A1, Match2D_PreCalc, X1->Nelements);
     360  ALLOCATE_PTR (A2, Match2D_PreCalc, X2->Nelements);
     361
     362  for (i = 0; i < X1->Nelements; i++) {
     363    A1[i].sR = sin(RAD_DEG*X1->elements.Flt[i]);
     364    A1[i].cR = cos(RAD_DEG*X1->elements.Flt[i]);
     365    A1[i].sD = sin(RAD_DEG*Y1->elements.Flt[i]);
     366    A1[i].cD = cos(RAD_DEG*Y1->elements.Flt[i]);
     367    N1[i] = i;
     368  }
     369  for (i = 0; i < X2->Nelements; i++) {
     370    A2[i].sR = sin(RAD_DEG*X2->elements.Flt[i]);
     371    A2[i].cR = cos(RAD_DEG*X2->elements.Flt[i]);
     372    A2[i].sD = sin(RAD_DEG*Y2->elements.Flt[i]);
     373    A2[i].cD = cos(RAD_DEG*Y2->elements.Flt[i]);
     374    N2[i] = i;
     375  }
     376
     377  // sort from one pole to the other
     378  sort_coords_indexonly (Y1->elements.Flt, X1->elements.Flt, N1, X1->Nelements);
     379  sort_coords_indexonly (Y2->elements.Flt, X2->elements.Flt, N2, X2->Nelements);
     380
     381  Nmatch = 0;
     382  for (i = j = 0; (i < X1->Nelements) && (j < X2->Nelements);) {
     383    I = N1[i];
     384    J = N2[j];
     385
     386    // we can use dY as minimal requirement: if dY > Radius, we are too far apart
     387    dY = Y1->elements.Flt[I] - Y2->elements.Flt[J];
     388
     389    if (dY <= -1.02*Radius) { i++; continue; }
     390    if (dY >= +1.02*Radius) { j++; continue; }
     391
     392    // look for all matches of list2() to list1(i)
     393    first_j = j;
     394    for (j = first_j; (dY > -1.02*Radius) && (j < X2->Nelements); j++) {
     395      J = N2[j];
     396
     397      dR = gcdist_PreCalc (&A1[I], &A2[J]);
     398      // dR = gcdist (X1->elements.Flt[I], Y1->elements.Flt[I], X2->elements.Flt[J], Y2->elements.Flt[J]);
     399
     400      if (dR < Radius) {
     401        index1->elements.Int[Nmatch] = I;
     402        index2->elements.Int[Nmatch] = J;
     403        if (radiusMatch) radiusMatch->elements.Flt[Nmatch] = dR;
     404
     405        // XXX track matches 1 and 2 with internal vector, save new nomatch index vectors
     406        // after this loop
     407
     408        Nmatch ++;
     409        if (Nmatch >= NMATCH) {
     410          NMATCH += DMATCH;
     411          REALLOCATE (index1->elements.Int, opihi_int, NMATCH);
     412          REALLOCATE (index2->elements.Int, opihi_int, NMATCH);
     413          if (radiusMatch) { REALLOCATE (radiusMatch->elements.Flt, opihi_flt, NMATCH); }
     414        }
     415      }
     416    }
     417    j = first_j;
     418    i++;
     419  }
     420  index1->Nelements = Nmatch;
     421  index2->Nelements = Nmatch;
     422  if (radiusMatch) radiusMatch->Nelements = Nmatch;
     423
     424  free (A1);
     425  free (A2);
     426
     427  free (N1);
     428  free (N2);
     429
     430  return (TRUE);
     431}
     432
     433// we are not defining a relative offset DX,DY for now
     434int find_matches2d_sphere_closest (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index) {
     435 
     436  off_t i, j, Jmin, Ji, I, J, *N1, *N2;
     437  double dY, dR, Rmin;
     438
     439  ResetVector (index, OPIHI_INT, X1->Nelements);
     440  for (i = 0; i < index->Nelements; i++) { index->elements.Int[i] = -1; }
     441
     442  ALLOCATE (N1, off_t, X1->Nelements);
     443  ALLOCATE (N2, off_t, X2->Nelements);
     444
     445  ALLOCATE_PTR (A1, Match2D_PreCalc, X1->Nelements);
     446  ALLOCATE_PTR (A2, Match2D_PreCalc, X2->Nelements);
     447
     448  for (i = 0; i < X1->Nelements; i++) {
     449    A1[i].sR = sin(RAD_DEG*X1->elements.Flt[i]);
     450    A1[i].cR = cos(RAD_DEG*X1->elements.Flt[i]);
     451    A1[i].sD = sin(RAD_DEG*Y1->elements.Flt[i]);
     452    A1[i].cD = cos(RAD_DEG*Y1->elements.Flt[i]);
     453    N1[i] = i;
     454  }
     455  for (i = 0; i < X2->Nelements; i++) {
     456    A2[i].sR = sin(RAD_DEG*X2->elements.Flt[i]);
     457    A2[i].cR = cos(RAD_DEG*X2->elements.Flt[i]);
     458    A2[i].sD = sin(RAD_DEG*Y2->elements.Flt[i]);
     459    A2[i].cD = cos(RAD_DEG*Y2->elements.Flt[i]);
     460    N2[i] = i;
     461  }
     462
     463  // sort from one pole to the other
     464  sort_coords_indexonly (Y1->elements.Flt, X1->elements.Flt, N1, X1->Nelements);
     465  sort_coords_indexonly (Y2->elements.Flt, X2->elements.Flt, N2, X2->Nelements);
     466
     467  for (i = j = 0; (i < X1->Nelements) && (j < X2->Nelements);) {
     468    I = N1[i];
     469    J = N2[j];
     470
     471    // we can use dY as minimal requirement: if dY > Radius, we are too far apart
     472    dY = Y1->elements.Flt[I] - Y2->elements.Flt[J];
     473
     474    if (dY <= -1.02*Radius) {
     475      // no match in list 2 to this entry
     476      index->elements.Int[I] = -1; // (probably not needed --- index is init'ed above)o
     477      i++;
     478      continue;
     479    }
     480    if (dY >= +1.02*Radius) { j++; continue; }
     481
     482    // look for all matches of list2() to list1(i)
     483    Jmin = -1;
     484    Rmin = Radius;
     485    for (Ji = j; (dY > -1.02*Radius) && (Ji < X2->Nelements); Ji++) {
     486      J = N2[Ji];
     487
     488      dR = gcdist_PreCalc (&A1[I], &A2[J]);
     489      // dR = gcdist (X1->elements.Flt[I], Y1->elements.Flt[I], X2->elements.Flt[J], Y2->elements.Flt[J]);
     490
     491      if (dR < Rmin) {
     492        Rmin = dR;
     493        Jmin = J;
     494      }
     495    }
     496   
     497
     498    // no match in list 2 to this entry
     499    if (Jmin == -1) {
     500      index->elements.Int[I] = -1;
     501      i++;
     502      continue;
     503    }
     504    index->elements.Int[I] = Jmin;
     505    i++;
     506  }
     507
     508  free (A1);
     509  free (A2);
     510
     511  free (N1);
     512  free (N2);
     513
     514  return (TRUE);
     515}
     516
     517
  • trunk/Ohana/src/opihi/cmd.data/stats-new.c

    r15274 r39926  
    129129  ALLOCATE (values, float, Nsample);
    130130   
    131   A = time(NULL);
    132   for (B = 0; A == time(NULL); B++);
    133   srand48(B);
     131  // srand48() is called by startup.c
    134132 
    135133  *buffer = (float *) matrix[0].buffer;
  • trunk/Ohana/src/opihi/dvo/imbox.c

    r37807 r39926  
    1515
    1616  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
     17
     18  char *xaxis = NULL;
     19  if ((N = get_argument (argc, argv, "-xaxis"))) {
     20    remove_argument (N, &argc, argv);
     21    xaxis = strcreate (argv[N]);
     22    remove_argument (N, &argc, argv);
     23  }
     24  char *yaxis = NULL;
     25  if ((N = get_argument (argc, argv, "-yaxis"))) {
     26    remove_argument (N, &argc, argv);
     27    yaxis = strcreate (argv[N]);
     28    remove_argument (N, &argc, argv);
     29  }
    1730
    1831  SOLO_PHU = FALSE;
     
    6174    // XXX currently, image uses an unsigned short for NX,XY. this is rather restrictive
    6275    // and needs to be at least checked.
    63     haveNx = gfits_scan (&header, "IMNAXIS1",   "%d", 1, &Nx);
    64     haveNy = gfits_scan (&header, "IMNAXIS2",   "%d", 1, &Ny);
     76    haveNx = FALSE;
     77    if (xaxis) {
     78      haveNx = gfits_scan (&header, xaxis, "%d", 1, &Nx);
     79    }
     80    if (!haveNx) {
     81      haveNx = gfits_scan (&header, "IMNAXIS1",   "%d", 1, &Nx);
     82    }
     83    if (!haveNx) {
     84        haveNx = gfits_scan (&header, "ZNAXIS1",   "%d", 1, &Nx);
     85    }
     86    if (!haveNx) {
     87        haveNx = gfits_scan (&header, "NAXIS1",   "%d", 1, &Nx);
     88    }
    6589
    66     if (!haveNx && !haveNy) {
    67         haveNx = gfits_scan (&header, "ZNAXIS1",   "%d", 1, &Nx);
     90    haveNy = FALSE;
     91    if (yaxis) {
     92      haveNy = gfits_scan (&header, yaxis, "%d", 1, &Ny);
     93    }
     94    if (!haveNy) {
     95      haveNy = gfits_scan (&header, "IMNAXIS2",   "%d", 1, &Ny);
     96    }
     97    if (!haveNy) {
    6898        haveNy = gfits_scan (&header, "ZNAXIS2",   "%d", 1, &Ny);
    6999    }
    70 
    71     if (!haveNx && !haveNy) {
    72         haveNx = gfits_scan (&header, "NAXIS1",   "%d", 1, &Nx);
     100    if (!haveNy) {
    73101        haveNy = gfits_scan (&header, "NAXIS2",   "%d", 1, &Ny);
    74102    }
     
    137165  free (Xvec.elements.Flt);
    138166  free (Yvec.elements.Flt);
     167  if (xaxis) free (xaxis);
     168  if (yaxis) free (yaxis);
    139169  return (TRUE);
    140170
  • trunk/Ohana/src/opihi/dvo/imdense.c

    r37807 r39926  
    44int imdense (int argc, char **argv) {
    55 
    6   long A, B;
    76  off_t i, Nimage;
    87  int kapa, N, status, NPTS;
     
    2726  Rmax = graphmode.coords.crval1 + 182.0;
    2827 
    29   A = time(NULL);
    30   for (B = 0; A == time(NULL); B++);
    31   srand48(B);
     28  // srand48() is called by startup.c
    3229
    3330  N = 0;
  • trunk/Ohana/src/opihi/dvo/skycat.c

    r39457 r39926  
    7878      if (table) {
    7979        int hostID = (regions[i][0].hostFlags & DATA_USE_BCK) ? regions[i][0].backupID : regions[i][0].hostID;
    80         int index = table->index[hostID];
    81         snprintf (hostfile, 1024, "%s/%s.cpt", table->hosts[index].pathname, regions[i][0].name);
     80        if (hostID) {
     81          int index = table->index[hostID];
     82          snprintf (hostfile, 1024, "%s/%s.cpt", table->hosts[index].pathname, regions[i][0].name);
     83        } else {
     84          strcpy (hostfile, skylist[0].filename[i]);
     85        }
    8286      } else {
    8387        strcpy (hostfile, skylist[0].filename[i]);
  • trunk/Ohana/src/opihi/lib.data/style_args.c

    r13479 r39926  
    2929  if ((N = get_argument (*argc, argv, "-lt"))) {
    3030    remove_argument (N, argc, argv);
    31     graphmode[0].ltype = atof(argv[N]);
     31    graphmode[0].ltype = KapaLineTypeFromString(argv[N]);
    3232    remove_argument (N, argc, argv);
    3333  }
     
    3939  if ((N = get_argument (*argc, argv, "-pt"))) {
    4040    remove_argument (N, argc, argv);
    41     graphmode[0].ptype = atof(argv[N]);
     41    graphmode[0].ptype = KapaPointStyleFromString(argv[N]);
    4242    remove_argument (N, argc, argv);
    4343  }
     
    6363  if ((N = get_argument (*argc, argv, "-x"))) {
    6464    remove_argument (N, argc, argv);
    65     graphmode[0].style = atof(argv[N]);
     65    graphmode[0].style = KapaPlotStyleFromString(argv[N]);
    6666    remove_argument (N, argc, argv);
    6767  }
  • trunk/Ohana/src/opihi/lib.shell/startup.c

    r33963 r39926  
    5151    gfits_set_unsign_mode (FALSE);
    5252   
     53    set_variable ("M_PI", M_PI);
     54    set_variable ("M_E",  M_E);
     55    set_variable ("M_c",  299792459.0); // meter / second
     56    set_variable ("M_c_cgs", 29979245900.0); // cm / second
     57
     58    set_variable ("M_h",  6.62607004e-34); // meter^2 kg / second (J s)
     59    set_variable ("M_h_cgs",  6.62607004e-27); // erg s
     60
     61    set_variable ("M_kB",  1.38064853e-23); // J / K
     62    set_variable ("M_kB_cgs",  1.38064853e-16); // erg / K
     63
    5364  /* check history file permission */
    5465  {
  • trunk/Ohana/src/photdbc/src/make_subcatalog.c

    r38441 r39926  
    77  int found;
    88  off_t i, j, k, offset;
    9   off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm, Nsecfilt;
     9  off_t Nm, Nsecfilt;
    1010  double mag, minMag, minSigma;
    1111  int keep, *secKeep;
     
    2727
    2828  /* we are moving only the subset of measurements from catalog[0] to subcatalog[0] */
    29   NAVERAGE = 50;
    30   NMEASURE = 1000;
    31   Nmeasure = Naverage = 0;
     29  off_t NAVERAGE = 50;   off_t Naverage = 0;
     30  off_t NMEASURE = 1000; off_t Nmeasure = 0;
     31  off_t NLENSING = 1000; off_t Nlensing = 0;
     32  off_t NLENSOBJ = 1000; off_t Nlensobj = 0;
     33  off_t NSTARPAR = 1000; off_t Nstarpar = 0;
     34  off_t NGALPHOT = 1000; off_t Ngalphot = 0;
     35
    3236  REALLOCATE (subcatalog[0].average, Average, NAVERAGE);
    3337  REALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt);
    3438  REALLOCATE (subcatalog[0].measure, Measure, NMEASURE);
     39  REALLOCATE (subcatalog[0].lensing, Lensing, NLENSING);
     40  REALLOCATE (subcatalog[0].lensobj, Lensobj, NLENSOBJ);
     41  REALLOCATE (subcatalog[0].starpar, StarPar, NSTARPAR);
     42  REALLOCATE (subcatalog[0].galphot, GalPhot, NGALPHOT);
    3543
    3644  for (i = 0; i < catalog[0].Naverage; i++) {
     
    3947    // XXX: temporary check make sure that this object belongs in this region
    4048    // used to fix the pole area in the reference catalog
    41     {
     49    if (0) {
    4250        double R = catalog[0].average[i].R;
    4351        double D = catalog[0].average[i].D;
     
    177185    subcatalog[0].average[Naverage].Nmissing = 0;
    178186    subcatalog[0].average[Naverage].Nmeasure = Nm;
     187
     188    // **** lensing
     189    Nm = 0;
     190    subcatalog[0].average[Naverage].lensingOffset = Nlensing;
     191    for (j = 0; j < catalog[0].average[i].Nlensing; j++) {
     192
     193      offset = catalog[0].average[i].lensingOffset + j;
     194
     195      subcatalog[0].lensing[Nlensing]        = catalog[0].lensing[offset];
     196      subcatalog[0].lensing[Nlensing].averef = Naverage;
     197
     198      Nlensing ++;
     199      Nm ++;
     200      if (Nlensing == NLENSING) {
     201        NLENSING += 1000;
     202        REALLOCATE (subcatalog[0].lensing, Lensing, NLENSING);
     203      }
     204    }
     205    subcatalog[0].average[Naverage].Nlensing = Nm;
     206
     207    // **** lensobj
     208    Nm = 0;
     209    subcatalog[0].average[Naverage].lensobjOffset = Nlensobj;
     210    for (j = 0; j < catalog[0].average[i].Nlensobj; j++) {
     211
     212      offset = catalog[0].average[i].lensobjOffset + j;
     213
     214      subcatalog[0].lensobj[Nlensobj]        = catalog[0].lensobj[offset];
     215
     216      Nlensobj ++;
     217      Nm ++;
     218      if (Nlensobj == NLENSOBJ) {
     219        NLENSOBJ += 1000;
     220        REALLOCATE (subcatalog[0].lensobj, Lensobj, NLENSOBJ);
     221      }
     222    }
     223    subcatalog[0].average[Naverage].Nlensobj = Nm;
     224
     225    // **** starpar
     226    Nm = 0;
     227    subcatalog[0].average[Naverage].starparOffset = Nstarpar;
     228    for (j = 0; j < catalog[0].average[i].Nstarpar; j++) {
     229
     230      offset = catalog[0].average[i].starparOffset + j;
     231
     232      subcatalog[0].starpar[Nstarpar]        = catalog[0].starpar[offset];
     233      subcatalog[0].starpar[Nstarpar].averef = Naverage;
     234
     235      Nstarpar ++;
     236      Nm ++;
     237      if (Nstarpar == NSTARPAR) {
     238        NSTARPAR += 1000;
     239        REALLOCATE (subcatalog[0].starpar, StarPar, NSTARPAR);
     240      }
     241    }
     242    subcatalog[0].average[Naverage].Nstarpar = Nm;
     243
     244    // **** galphot
     245    Nm = 0;
     246    subcatalog[0].average[Naverage].galphotOffset = Ngalphot;
     247    for (j = 0; j < catalog[0].average[i].Ngalphot; j++) {
     248
     249      offset = catalog[0].average[i].galphotOffset + j;
     250
     251      subcatalog[0].galphot[Ngalphot]        = catalog[0].galphot[offset];
     252      subcatalog[0].galphot[Ngalphot].averef = Naverage;
     253
     254      Ngalphot ++;
     255      Nm ++;
     256      if (Ngalphot == NGALPHOT) {
     257        NGALPHOT += 1000;
     258        REALLOCATE (subcatalog[0].galphot, GalPhot, NGALPHOT);
     259      }
     260    }
     261    subcatalog[0].average[Naverage].Ngalphot = Nm;
     262
    179263    Naverage ++;
    180264    if (Naverage == NAVERAGE) {
     
    187271  REALLOCATE (subcatalog[0].measure, Measure, MAX (Nmeasure, 1));
    188272  REALLOCATE (subcatalog[0].secfilt, SecFilt, Nsecfilt*MAX (Naverage, 1));
     273  REALLOCATE (subcatalog[0].lensing, Lensing, MAX (Nlensing, 1));
     274  REALLOCATE (subcatalog[0].lensobj, Lensobj, MAX (Nlensobj, 1));
     275  REALLOCATE (subcatalog[0].starpar, StarPar, MAX (Nstarpar, 1));
     276  REALLOCATE (subcatalog[0].galphot, GalPhot, MAX (Ngalphot, 1));
     277
    189278  subcatalog[0].Naverage = Naverage;
    190279  subcatalog[0].Nmeasure = Nmeasure;
    191280  subcatalog[0].Nsecfilt = Nsecfilt;
     281  subcatalog[0].Nlensing = Nlensing;
     282  subcatalog[0].Nlensobj = Nlensobj;
     283  subcatalog[0].Nstarpar = Nstarpar;
     284  subcatalog[0].Ngalphot = Ngalphot;
     285
    192286  subcatalog[0].Nsecfilt_mem = Naverage * Nsecfilt;
    193287
  • trunk/Ohana/src/photdbc/src/photdbc_catalogs.c

    r38986 r39926  
    2626    incatalog.filename  = hostID ? hostfile : skylist[0].filename[i];
    2727    incatalog.Nsecfilt = GetPhotcodeNsecfilt ();
    28     incatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT;
     28
     29    incatalog.catflags    = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT;
     30    incatalog.catflags   |= DVO_LOAD_MEASURE | DVO_LOAD_MISSING;
     31    incatalog.catflags   |= DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ;
     32    incatalog.catflags   |= DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT;
    2933
    3034    // an error exit status here is a significant error
     
    5761    outcatalog.catcompress = CATCOMPRESS ? dvo_catalog_catcompress (CATCOMPRESS) : incatalog.catcompress; // set the default catcompress from config data
    5862    outcatalog.Nsecfilt    = incatalog.Nsecfilt;                 // inherit from the incatalog
    59     outcatalog.catflags    = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT;
     63
     64    outcatalog.catflags    = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT;
     65    outcatalog.catflags   |= DVO_LOAD_MEASURE | DVO_LOAD_MISSING;
     66    outcatalog.catflags   |= DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ;
     67    outcatalog.catflags   |= DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT;
    6068
    6169    // output catalogs always represent the same skyregions as the input catalogs
  • trunk/Ohana/src/relastro/include/relastro.h

    r39693 r39926  
    3333typedef enum {OP_NONE, OP_IMAGES, OP_HIGH_SPEED, OP_MERGE_SOURCE, OP_UPDATE_OBJECTS, OP_UPDATE_OFFSETS, OP_LOAD_OBJECTS, OP_HPM, OP_PARALLEL_REGIONS, OP_PARALLEL_IMAGES, OP_REPAIR_STACKS, OP_REPAIR_WARPS, OP_REPAIR_OBJECT_ID} RelastroOp;
    3434
    35 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS} FitTarget;
     35typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, SET_CHIPS, TARGET_MOSAICS} FitTarget;
    3636
    3737typedef enum {
     
    144144  int Nfit;
    145145  int converged;
     146  int useWeight;
     147
    146148} FitAstromResult;
    147149
     
    296298} CheckMeasureResult;
    297299
    298 # define ID_MEAS_OBJECT_HAS_2MASS ID_MEAS_POOR_PHOTOM
     300// # define ID_MEAS_OBJECT_HAS_2MASS ID_MEAS_POOR_PHOTOM
    299301
    300302/* global variables set in parameter file */
     
    315317int    PARALLEL_REGIONS_MANUAL;
    316318char  *MANUAL_UNIQUER;
     319int    CATCH_UP;
    317320
    318321int          HOST_ID;
     
    352355int    VERBOSE2;
    353356
     357float  TEST_SCALE;
     358char  *GALAXY_MODEL;
     359
    354360int    USE_FIXED_PIXCOORDS;
    355361int    USE_GALAXY_MODEL;
     
    363369int    USE_IMAGE_COORDS_FOR_REPAIR;
    364370int    USE_ALL_IMAGES;
     371int    KEEP_ALL_IMAGES_RA;
    365372int    CHECK_MEASURE_TO_IMAGE;
     373
     374int    SKIP_PS1_CHIP;
     375int    SKIP_PS1_STACK;
     376int    SKIP_HSC;
     377int    SKIP_CFH;
     378
     379int    UPDATE_PS1_STACK_MEASURE;
     380int    UPDATE_PS1_CHIP_MEASURE;
     381int    UPDATE_HSC_MEASURE;
     382int    UPDATE_CFH_MEASURE;
     383
     384int    APPLY_PROPER_MOTION;
    366385
    367386int    RESET;
     
    383402int    CHIPMAP;
    384403
     404int    *ChipMapLoop;
     405int    *ChipOrderLoop;
     406char   *ChipMapLoopStr;
     407char   *ChipOrderLoopStr;
     408
    385409int    N_BOOTSTRAP_SAMPLES;
    386410
     
    407431
    408432float *LoopWeight2MASS;
     433char *LoopWeight2MASSstr;
     434
    409435float *LoopWeightTycho;
    410 char *LoopWeight2MASSstr;
    411436char *LoopWeightTychostr;
     437
     438float *LoopWeightGAIA;
     439char *LoopWeightGAIAstr;
    412440
    413441int ImagSelect;
     
    433461
    434462FitMode FIT_MODE;
     463int USE_IRLS;
     464int ALLOW_IRLS;
    435465
    436466RelastroOp RELASTRO_OP;
     
    498528void          initGridBins        PROTO((Catalog *catalog, int Ncatalog));
    499529void          initImageBins       PROTO((Catalog *catalog, int Ncatalog, int FULLINIT));
    500 void          initImages          PROTO((Image *input, off_t *line_number, off_t N));
     530void          initImages          PROTO((Image *input, off_t *line_number, off_t N, int isSubset));
    501531void          freeImages          PROTO((char *dbImagePtr));
    502532void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog));
     
    744774int isGPC1stack (int photcode);
    745775int isGPC1warp (int photcode);
     776int isHSCchip (int photcode);
     777int isCFHchip (int photcode);
    746778
    747779int save_astrom_table ();
  • trunk/Ohana/src/relastro/src

  • trunk/Ohana/src/relastro/src/BootstrapOps.c

    r39457 r39926  
    7777    case FIT_RESULT_RA:
    7878      // result->Ro = median;
    79       result->dRo = sigma;
     79      result->dRo = MAX(sigma, result->dRo);
    8080      break;
    8181    case FIT_RESULT_DEC:
    8282      // result->Do = median;
    83       result->dDo = sigma;
     83      result->dDo = MAX(sigma, result->dDo);
    8484      break;
    8585    case FIT_RESULT_uR:
    8686      // result->uR = median;
    87       result->duR = sigma;
     87      result->duR = MAX(sigma, result->duR);
    8888      break;
    8989    case FIT_RESULT_uD:
    9090      // result->uD = median;
    91       result->duD = sigma;
     91      result->duD = MAX(sigma, result->duD);
    9292      break;
    9393    case FIT_RESULT_PLX:
    9494      // result->p = median;
    95       result->dp = sigma;
     95      result->dp = MAX(sigma, result->dp);
    9696      break;
    9797    default:
  • trunk/Ohana/src/relastro/src/BrightCatalog.c

    r39457 r39926  
    353353  /*** MeasureTiny ***/
    354354  {
    355     ohana_memcheck (1);
     355    // ohana_memcheck (1);
    356356    gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY");
    357357
    358     ohana_memcheck (1);
     358    // ohana_memcheck (1);
    359359
    360360    gfits_define_bintable_column (&theader, "D", "RA",       "ra",                         "degrees", 1.0, 0.0);
     
    429429    gfits_set_bintable_column (&theader, &ftable, "RA",         R,         catalog->Nmeasure);
    430430
    431     fprintf (stderr, "--------------- after set_bintable RA --------------");
    432     ohana_memdump_file (stderr, TRUE);
     431    // fprintf (stderr, "--------------- after set_bintable RA --------------");
     432    // ohana_memdump_file (stderr, TRUE);
    433433   
    434434    gfits_set_bintable_column (&theader, &ftable, "DEC",        D,         catalog->Nmeasure);
  • trunk/Ohana/src/relastro/src/ConfigInit.c

    r39396 r39926  
    8484  SetZeroPoint (25.0);
    8585
    86   if (USE_GALAXY_MODEL) {
    87     if (!InitGalaxyModel ("FEAST-HIPPARCOS")) {
    88       fprintf (stderr, "failed to init galaxy model\n");
    89       exit (2);
    90     }
    91   }
    92 
    9386  FreeConfigFile();
    9487  free (config);
  • trunk/Ohana/src/relastro/src/FitAstromOps.c

    r39610 r39926  
    257257  fit->converged = FALSE;
    258258 
     259  // this is an input value
     260  // if true, use the IRLS modified weight
     261  fit->useWeight = FALSE;
     262
    259263  return;
    260264}
  • trunk/Ohana/src/relastro/src/FitChip.c

    r39457 r39926  
    7878      order_use = MIN(MIN(order_use, CHIPMAP), 6); // can only go up to 6th order map (can be user limited)
    7979    } else {
    80       order_use = MIN(order_use, 3); // can only go up to 3rd order for polynomials
     80      order_use = MIN(MIN(order_use, CHIPORDER), 3); // can only go up to 3rd order for polynomials
    8181    }
    8282
     
    206206  if (VERBOSE2) fprintf (stderr, "fit sigma: %f (%f, %f) : full: %f (%f, %f), scatter limit: %f (%d full, %d bright, %d fit, %d all) (%d %d %d %d %d)\n", dRsig, dLsig, dMsig, dRsigFull, dLsigFull, dMsigFull, dRmax, NstatFull, Nstat, fit[0].Npts, Nmatch, nMask1, nMask2, nMask3, nMask4, nMask5);
    207207
    208   image[0].dXpixSys = dLsig;
    209   image[0].dYpixSys = dMsig;
     208  // need to convert dLsig, dMsig back to pixel scale (or up to arcsec)
     209
     210  float plateScale;
     211  if (image[0].coords.mosaic) {
     212    // NOTE: for the full pixel to sky plate scale, use this:
     213    // float plateScaleX = 3600.0*image[0].coords.mosaic->cdelt1*image[0].coords.cdelt1;
     214    // float plateScaleY = 3600.0*image[0].coords.mosaic->cdelt2*image[0].coords.cdelt2;
     215
     216    // since we are compare L,M values, just need to compensate for focal plate to sky:
     217    float plateScaleX = 3600.0*fabs(image[0].coords.mosaic->cdelt1);
     218    float plateScaleY = 3600.0*fabs(image[0].coords.mosaic->cdelt2);
     219    plateScale = 0.5*(plateScaleX + plateScaleY);
     220  } else {
     221    // since we are compare L,M values, just need to compensate for arcsec vs degrees:
     222    plateScale = 3600.0;
     223  }
     224
     225  image[0].dXpixSys = plateScale*dLsig;
     226  image[0].dYpixSys = plateScale*dMsig;
    210227  image[0].nFitAstrom = fit[0].Npts;
    211228
    212   // fprintf (stderr, "%s %6.3f %4d %4d\n", image[0].name, image[0].refColor, Ncolor, image[0].nFitAstrom);
     229  if (VERBOSE2) fprintf (stderr, "%s | %6.3f %6.3f | %4d %4d | %6.3f %6.3f\n", image[0].name, image[0].refColorRed, image[0].refColorBlue, Ncolor, image[0].nFitAstrom, image[0].dXpixSys, image[0].dYpixSys);
    213230
    214231  if (fit) fit_free (fit);
  • trunk/Ohana/src/relastro/src/FitPM.c

    r39612 r39926  
    2525  }
    2626
     27  fit->useWeight = FALSE; // Ordinary Least Squares
    2728  if (!FitPM_MinChisq (fit, data, points, Npoints)) return FALSE;
    2829  if (!FitPM_SetChisq (fit, data, points, Npoints)) return FALSE;
     
    4748 
    4849  // Solve OLS equation 
     50  fit->useWeight = FALSE; // Ordinary Least Squares
    4951  if (!FitPM_MinChisq(fit, data, points, Npoints)) {
    5052    return(FALSE);
     
    6971
    7072  // Iteratively reweight and solve
    71   double sigma_hat = 0.0; // save for the error model
     73  // double sigma_hat = 0.0; // save for the error model
    7274  int converged = FALSE;
    7375  int iterations = 0;
     
    9092
    9193    // Solve with the new weights
     94    fit->useWeight = TRUE; // Reweighted Least Squares
    9295    if (!FitPM_MinChisq(fit, data, points, Npoints)) {
    9396
     
    104107        points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    105108      }
    106       sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     109      // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    107110      break;
    108111    }
     
    119122      points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    120123    }
    121     sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     124    // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    122125   
    123126    // Check convergence
     
    159162  // NOTE EAM: in tests (fitpm.c), they seem to be too large by a factor of ~5.37
    160163  if (data->getError) {
    161     double ax = 0.0, ay = 0.0;
    162     double bx = 0.0, by = 0.0;
    163 
    164     for (i = 0; i < Npoints; i++) {
    165       ax += dpsi_cauchy(points[i].rx / points[i].dX);
    166       ay += dpsi_cauchy(points[i].ry / points[i].dY);
    167 
    168       bx += SQ(points[i].Wx);
    169       by += SQ(points[i].Wy);
    170     }
    171     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
    172     ay /= 1.0 * Npoints;
    173     bx /= 1.0 * (Npoints - data->Nterms); // mean(psi^2(r)) * (N / (N-p))
    174     by /= 1.0 * (Npoints - data->Nterms);
    175  
    176     double lambda_x = 1.0 + (data->Nterms / Npoints) * (1 - ax) / ax;
    177     double lambda_y = 1.0 + (data->Nterms / Npoints) * (1 - ay) / ay;
    178  
    179     double sigma_robust_x = lambda_x * sqrt(bx) * sigma_hat * 2.385 / ax;
    180     double sigma_robust_y = lambda_y * sqrt(by) * sigma_hat * 2.385 / ay;
    181 
    182     // This is actually sigma^2, as that's the factor in the covariance (dumouchel 4.1)
    183     double sigma_final_x  = MAX(SQ(sigma_robust_x), (2 * Npoints * SQ(sigma_robust_x) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    184     double sigma_final_y  = MAX(SQ(sigma_robust_y), (2 * Npoints * SQ(sigma_robust_y) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    185 
    186     fit[0].dRo = sqrt(data->Cov[0][0]);
    187     fit[0].duR = sqrt(data->Cov[1][1]);
    188     fit[0].dDo = sqrt(data->Cov[2][2]);
    189     fit[0].duD = sqrt(data->Cov[3][3]);
    190 
    191     fit[0].dRo *= sigma_final_x;
    192     fit[0].duR *= sigma_final_x;
    193     fit[0].dDo *= sigma_final_y;
    194     fit[0].duD *= sigma_final_y;
     164    FitAstromResult fitErrors;
     165    FitAstromResultInit (&fitErrors);
     166    fitErrors.useWeight = FALSE;
     167
     168    FitPM_MinChisq(&fitErrors, data, points, Npoints);
     169
     170    // we use the errors from a simple OLS, ignoring masked points
     171    fit[0].dRo = fitErrors.dRo;
     172    fit[0].duR = fitErrors.duR;
     173    fit[0].dDo = fitErrors.dDo;
     174    fit[0].duD = fitErrors.duD;
    195175  }
    196176
     
    212192    Nfit ++;
    213193
    214     wx = points[i].qx;
    215     wy = points[i].qy;
     194    if (fit->useWeight) {
     195      wx = points[i].qx;
     196      wy = points[i].qy;
     197    } else {
     198      wx = points[i].Qx;
     199      wy = points[i].Qy;
     200    }
    216201
    217202    Wx += wx;
  • trunk/Ohana/src/relastro/src/FitPMandPar.c

    r39612 r39926  
    2525  }
    2626
     27  fit->useWeight = FALSE; // Ordinary Least Squares
    2728  if (!FitPMandPar_MinChisq (fit, data, points, Npoints)) return FALSE;
    2829  if (!FitPMandPar_SetChisq (fit, data, points, Npoints)) return FALSE;
     
    4748 
    4849  // Solve OLS equation: failure here means the chisq matrix is degenerate, give up entirely
     50  fit->useWeight = FALSE; // Ordinary Least Squares
    4951  if (!FitPMandPar_MinChisq(fit, data, points, Npoints)) {
    5052    return(FALSE);
     
    6971
    7072  // Iteratively reweight and solve
    71   double sigma_hat = 0.0; // save for the error model
     73  // double sigma_hat = 0.0; // save for the error model
    7274  int converged = FALSE;
    7375  int iterations = 0;
     
    9092
    9193    // Solve with the new weights
     94    fit->useWeight = TRUE; // Reweighted Least Squares
    9295    if (!FitPMandPar_MinChisq(fit, data, points, Npoints)) {
    9396
     
    105108        points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    106109      }
    107       sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     110      // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    108111      break;
    109112    }
     
    120123      points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    121124    }
    122     sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     125    // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    123126
    124127    // Check convergence
     
    157160  }
    158161
    159   // this section calculates the formal error on the weighted fit using the covariance values
    160   // NOTE EAM: in tests (fitpm.c), they seem to be too large by a factor of ~5.37
     162  // this section calculates the formal error on the regular (unweighted) fit using the covariance values
     163  // NOTE 20160929 : use only the unmasked points to calculate the error
    161164  if (data->getError) {
    162     double ax = 0.0, ay = 0.0;
    163     double bx = 0.0, by = 0.0;
    164 
    165     for (i = 0; i < Npoints; i++) {
    166       ax += dpsi_cauchy(points[i].rx / points[i].dX);
    167       ay += dpsi_cauchy(points[i].ry / points[i].dY);
    168 
    169       bx += SQ(points[i].Wx);
    170       by += SQ(points[i].Wy);
    171     }
    172     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
    173     ay /= 1.0 * Npoints;
    174     bx /= 1.0 * (Npoints - data->Nterms); // mean(psi^2(r)) * (N / (N-p))
    175     by /= 1.0 * (Npoints - data->Nterms);
    176  
    177     double lambda_x = 1.0 + (data->Nterms / Npoints) * (1 - ax) / ax;
    178     double lambda_y = 1.0 + (data->Nterms / Npoints) * (1 - ay) / ay;
    179  
    180     double sigma_robust_x = lambda_x * sqrt(bx) * sigma_hat * 2.385 / ax;
    181     double sigma_robust_y = lambda_y * sqrt(by) * sigma_hat * 2.385 / ay;
    182 
    183     // This is actually sigma^2, as that's the factor in the covariance (dumouchel 4.1)
    184     double sigma_final_x  = MAX(SQ(sigma_robust_x), (2 * Npoints * SQ(sigma_robust_x) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    185     double sigma_final_y  = MAX(SQ(sigma_robust_y), (2 * Npoints * SQ(sigma_robust_y) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    186 
    187     fit[0].dRo = sqrt(data->Cov[0][0]);
    188     fit[0].duR = sqrt(data->Cov[1][1]);
    189     fit[0].dDo = sqrt(data->Cov[2][2]);
    190     fit[0].duD = sqrt(data->Cov[3][3]);
    191     fit[0].dp  = sqrt(data->Cov[4][4]);
    192 
    193     fit[0].dRo *= sigma_final_x;
    194     fit[0].duR *= sigma_final_x;
    195     fit[0].dDo *= sigma_final_y;
    196     fit[0].duD *= sigma_final_y;
    197     fit[0].dp  *= sqrt(sigma_final_x * sigma_final_y);
     165    FitAstromResult fitErrors;
     166    FitAstromResultInit (&fitErrors);
     167    fitErrors.useWeight = FALSE;
     168
     169    FitPMandPar_MinChisq(&fitErrors, data, points, Npoints);
     170
     171    // we use the errors from a simple OLS, ignoring masked points
     172    fit[0].dRo = fitErrors.dRo;
     173    fit[0].duR = fitErrors.duR;
     174    fit[0].dDo = fitErrors.dDo;
     175    fit[0].duD = fitErrors.duD;
     176    fit[0].dp  = fitErrors.dp;
    198177  }
    199178
     
    219198    Nfit ++;
    220199
    221     wx = points[i].qx;
    222     wy = points[i].qy;
     200    if (fit->useWeight) {
     201      wx = points[i].qx;
     202      wy = points[i].qy;
     203    } else {
     204      wx = points[i].Qx;
     205      wy = points[i].Qy;
     206    }
    223207
    224208    Wx += wx;
  • trunk/Ohana/src/relastro/src/FitPosPMfixed.c

    r39612 r39926  
    5454  }
    5555
     56  fit->useWeight = FALSE; // Ordinary Least Squares
    5657  if (!FitPosPMfixed_MinChisq (fit, data, points, Npoints)) {
    5758    if (!FitPosPMfixed_Single (fit, points, Npoints)) return FALSE;
     
    8384 
    8485  // Solve OLS equation 
     86  fit->useWeight = FALSE; // Ordinary Least Squares
    8587  if (!FitPosPMfixed_MinChisq(fit, data, points, Npoints)) {
    8688    return(FALSE);
     
    105107
    106108  // Iteratively reweight and solve
    107   double sigma_hat = 0.0; // save for the error model
     109  // double sigma_hat = 0.0; // save for the error model
    108110  int converged = FALSE;
    109111  int iterations = 0;
     
    126128
    127129    // Solve with the new weights
     130    fit->useWeight = TRUE; // Reweighted Least Squares
    128131    if (!FitPosPMfixed_MinChisq(fit, data, points, Npoints)) {
    129132
     
    138141        points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    139142      }
    140       sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     143      // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    141144      break;
    142145    }
     
    153156      points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    154157    }
    155     sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     158    // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    156159   
    157160    // Check convergence
     
    193196  // NOTE EAM: in tests (fitpm.c), they seem to be too large by a factor of ~5.37
    194197  if (data->getError) {
    195     double ax = 0.0, ay = 0.0;
    196     double bx = 0.0, by = 0.0;
    197 
    198     for (i = 0; i < Npoints; i++) {
    199       ax += dpsi_cauchy(points[i].rx / points[i].dX);
    200       ay += dpsi_cauchy(points[i].ry / points[i].dY);
    201 
    202       bx += SQ(points[i].Wx);
    203       by += SQ(points[i].Wy);
    204     }
    205     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
    206     ay /= 1.0 * Npoints;
    207     bx /= 1.0 * (Npoints - data->Nterms); // mean(psi^2(r)) * (N / (N-p))
    208     by /= 1.0 * (Npoints - data->Nterms);
    209  
    210     double lambda_x = 1.0 + (data->Nterms / Npoints) * (1 - ax) / ax;
    211     double lambda_y = 1.0 + (data->Nterms / Npoints) * (1 - ay) / ay;
    212  
    213     double sigma_robust_x = lambda_x * sqrt(bx) * sigma_hat * 2.385 / ax;
    214     double sigma_robust_y = lambda_y * sqrt(by) * sigma_hat * 2.385 / ay;
    215 
    216     // This is actually sigma^2, as that's the factor in the covariance (dumouchel 4.1)
    217     double sigma_final_x  = MAX(SQ(sigma_robust_x), (2 * Npoints * SQ(sigma_robust_x) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    218     double sigma_final_y  = MAX(SQ(sigma_robust_y), (2 * Npoints * SQ(sigma_robust_y) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    219 
    220     fit[0].dRo = sqrt(data->Cov[0][0]);
    221     fit[0].dDo = sqrt(data->Cov[1][1]);
    222 
    223     fit[0].dRo *= sigma_final_x;
    224     fit[0].dDo *= sigma_final_y;
     198    FitAstromResult fitErrors;
     199    FitAstromResultInit (&fitErrors);
     200    fitErrors.useWeight = FALSE;
     201
     202    FitPosPMfixed_MinChisq(&fitErrors, data, points, Npoints);
     203
     204    // we use the errors from a simple OLS, ignoring masked points
     205    fit[0].dRo = fitErrors.dRo;
     206    fit[0].duR = fitErrors.duR;
     207    fit[0].dDo = fitErrors.dDo;
     208    fit[0].duD = fitErrors.duD;
     209    fit[0].dp  = fitErrors.dp;
    225210  }
    226211
     
    242227    Nfit ++;
    243228
    244     wx = points[i].qx;
    245     wy = points[i].qy;
     229    if (fit->useWeight) {
     230      wx = points[i].qx;
     231      wy = points[i].qy;
     232    } else {
     233      wx = points[i].Qx;
     234      wy = points[i].Qy;
     235    }
    246236
    247237    Wx += wx;
  • trunk/Ohana/src/relastro/src/GetAstromError.c

    r39457 r39926  
    4848  if (isnan(code[0].astromErrSys)) return NAN;
    4949
     50  if (measure[0].photcode == 1030) {
     51    if (mode == ERROR_MODE_RA) {
     52      dPobs = pow(10.0, (6.0 * measure[0].dXccd - 3.0));  // dXccd is a value in pixels
     53    }
     54    if (mode == ERROR_MODE_DEC) {
     55      dPobs = pow(10.0, (6.0 * measure[0].dYccd - 3.0));  // dXccd is a value in pixels
     56    }
     57  }
     58
    5059  AS    = code[0].astromErrScale;
    5160  MS    = code[0].astromErrMagScale;
     
    6978  // to match the 2MASS / Tycho / ICRS reference frame.  As Nloop gets higher, the weight
    7079  // needs to drop to allow the ps1 measurements to drive the solution
     80  int isGAIA   = USE_GALAXY_MODEL && !isImage && (measure[0].photcode == 1030);
    7181  int is2MASS  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2011) && (measure[0].photcode <= 2013);
    7282  int isTycho  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2020) && (measure[0].photcode <= 2021);
     83
     84  int hasGAIA  = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_GAIA);
    7385  int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
     86  int hasTycho = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_TYCHO);
    7487
    7588  // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
     
    7992    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
    8093  }
     94  if (hasGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     95    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
     96  }
     97  if (hasTycho && LoopWeightTycho && (Nloop >= 0)) {
     98    dPtotal = dPtotal / LoopWeightTycho[Nloop];
     99  }
     100
    81101  if (is2MASS && LoopWeight2MASS && (Nloop >= 0)) {
    82102    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
     103  }
     104  if (isGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     105    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
    83106  }
    84107  if (isTycho && LoopWeightTycho && (Nloop >= 0)) {
     
    120143  // do not raise an exception, just send back the result
    121144  if (isnan(code[0].astromErrSys)) return NAN;
     145
     146  if (measure[0].photcode == 1030) {
     147    if (mode == ERROR_MODE_RA) {
     148      dPobs = pow(10.0, (6.0 * measure[0].dXccd - 3.0));  // dXccd is a value in pixels
     149    }
     150    if (mode == ERROR_MODE_DEC) {
     151      dPobs = pow(10.0, (6.0 * measure[0].dYccd - 3.0));  // dXccd is a value in pixels
     152    }
     153  }
    122154
    123155  AS    = code[0].astromErrScale;
     
    143175  // to match the 2MASS / Tycho / ICRS reference frame.  As Nloop gets higher, the weight
    144176  // needs to drop to allow the ps1 measurements to drive the solution
     177  int isGAIA   = USE_GALAXY_MODEL && !isImage && (measure[0].photcode == 1030);
    145178  int is2MASS  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2011) && (measure[0].photcode <= 2013);
    146179  int isTycho  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2020) && (measure[0].photcode <= 2021);
     180
     181  int hasGAIA  = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_GAIA);
    147182  int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
     183  int hasTycho = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_TYCHO);
    148184
    149185  // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
     
    153189    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
    154190  }
     191  if (hasGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     192    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
     193  }
     194  if (hasTycho && LoopWeightTycho && (Nloop >= 0)) {
     195    dPtotal = dPtotal / LoopWeightTycho[Nloop];
     196  }
     197
    155198  if (is2MASS && LoopWeight2MASS) {
    156199    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
     200  }
     201  if (isGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     202    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
    157203  }
    158204  if (isTycho && LoopWeightTycho) {
  • trunk/Ohana/src/relastro/src/ImageOps.c

    r39580 r39926  
    66static Image        *image;   // list of available images
    77static off_t        Nimage;   // number of available images
     8static int         isImageSubset;
    89
    910// if we read only a subset of the rows from the Image FITS, LineNumber tells us to which row
     
    7879}
    7980
    80 void initImages (Image *input, off_t *line_number, off_t N) {
     81void initImages (Image *input, off_t *line_number, off_t N, int isSubset) {
    8182
    8283  off_t i;
    8384
     85  isImageSubset = isSubset;
    8486  image = input;
    8587  LineNumber = line_number;
     
    136138  // we call gfits_db_free as well as this function.  sometimes those point at the same
    137139  // memory location, in which case we should only do the free once.
    138   if ((void *) dbImagePtr != (void *) image) free (image);
     140  if (((void *) dbImagePtr != (void *) image) && isImageSubset) free (image);
    139141  free_astrom_table();
    140142}
     
    793795    ref[i].D = catalog[c].average[n].D;
    794796   
     797    int XVERB = FALSE;
     798    XVERB |= (catalog[c].average[n].objID == OBJ_ID_SRC) && (catalog[c].average[n].catID == CAT_ID_SRC);
     799    XVERB |= (catalog[c].average[n].objID == OBJ_ID_DST) && (catalog[c].average[n].catID == CAT_ID_DST);
     800    if (XVERB) {
     801      fprintf (stderr, "found test object\n");
     802    }
     803
    795804    // if we are applying the galaxy model, move the reference position...
    796     if (USE_GALAXY_MODEL) {
     805    if (APPLY_PROPER_MOTION) {
    797806      // apply proper-motion from average position to measure epoch:
    798807      float dTime = (measure[0].t - catalog[c].average[n].Tmean) / (86400*365.25) ; // time relative to Tmean in years
     
    934943}
    935944
    936 # if (0)
    937 /** lifted from relphot/StarOps.clean_measures */
    938 void FlagOutliers2D(Catalog *catalog);
    939 
    940 // operates on Full values (not tiny)
    941 void FlagOutliers (Catalog *catalog) {
    942 
    943   // XXX FlagOutliers is now just using FlagOutliers2D
    944   FlagOutliers2D(catalog);
    945   return;
    946 
    947   int Ndel, Nave;
    948   off_t i, j, k, m, N, Nmax, TOOFEW, Nsecfilt;
    949   double Ns, theta, x, y;
    950   double *R, *D, *dR, *dD;
    951   StatType statsR, statsD;
    952 
    953   Nsecfilt = GetPhotcodeNsecfilt();
    954   assert(catalog[0].Nsecfilt == Nsecfilt);
    955 
    956   if (VERBOSE2) fprintf (stderr, "marking poor measures\n");
    957   Nmax = 0;
    958   for (i = 0; i < catalog[0].Naverage; i++) {
    959     Nmax = MAX (Nmax, catalog[0].average[i].Nmeasure);
    960   }
    961 
    962   ALLOCATE (R, double, Nmax);
    963   ALLOCATE (D, double, Nmax);
    964   ALLOCATE (dR, double, Nmax);
    965   ALLOCATE (dD, double, Nmax);
    966 
    967   /* it makes no sense to mark 3-sigma outliers with <5 measurements */
    968   TOOFEW = MAX (5, SRC_MEAS_TOOFEW);
    969 
    970   Ns = CLIP_THRESH;
    971   Ndel = Nave = 0;
    972      
    973   /* loop over each object in the catalog */
    974   for (j = 0; j < catalog[0].Naverage; j++) {
    975    
    976     // pointer to this set of measurements
    977     m = catalog[0].average[j].measureOffset;
    978     Measure *measure = &catalog[0].measure[m];
    979 
    980     /* accumulate list of valid measurements */
    981     N = 0;
    982     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    983       // skip measurements based on user selected criteria
    984       if (!MeasFilterTest(&measure[k], FALSE)) continue;
    985       R[N] = measure[k].R;
    986       D[N] = measure[k].D;
    987       dR[N] = GetAstromError (&measure[k], ERROR_MODE_RA);
    988       dD[N] = GetAstromError (&measure[k], ERROR_MODE_DEC);
    989       if (isnan(R[N]) || isnan(D[N])) continue;
    990       N++;
    991     }
    992     if (N <= TOOFEW) continue;
    993    
    994     /* 3-sigma clip based on stats of inner 50% */
    995     initstats ("MEAN");
    996     liststats (R, dR, N, &statsR);
    997     liststats (D, dD, N, &statsD);
    998    
    999     statsR.sigma = MAX (MIN_ERROR, statsR.sigma);
    1000     statsD.sigma = MAX (MIN_ERROR, statsD.sigma);
    1001    
    1002     /* compare per-object distance to this standard deviation, and flag outliers*/
    1003     N = 0;
    1004     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1005       // reset flag on each invocation
    1006       measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM;
    1007 
    1008       // skip measurements based on user selected criteria
    1009       if (!MeasFilterTest(&measure[k], FALSE)) continue;
    1010      
    1011       x = measure[k].R - statsR.median;
    1012       y = measure[k].D - statsD.median;
    1013       theta = atan2(y,x);
    1014       if ((x*x + y*y) > (SQR(statsR.sigma * Ns * cos(theta)) +
    1015                          SQR(statsD.sigma * Ns * sin(theta)))) {   
    1016         measure[k].dbFlags |= ID_MEAS_POOR_ASTROM;
    1017         Ndel++;
    1018       }
    1019       N++;
    1020       Nave ++;
    1021     }
    1022 
    1023     // examine results
    1024     // relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, catalog[0].average[j].Nmeasure, statsR, statsD, Ns);
    1025   }
    1026  
    1027   if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave);
    1028   free (R);
    1029   free (dR);
    1030   free (D);
    1031   free (dD);
    1032 }
    1033 
    1034 
    1035 /** an alternative outlier rejection scheme */
    1036 void FlagOutliers2D (Catalog *catalog) {
    1037 
    1038   int Ndel, Nave;
    1039   off_t i, j, k, m, N, Nmax, TOOFEW, Nsecfilt;
    1040   double *index;
    1041   double Ns, theta, x, y;
    1042   double *R, *D, *dR, *dD, *d2;
    1043   StatType statsR, statsD;
    1044 
    1045   // XXX we are not going to use this for now
    1046   return;
    1047 
    1048   Nsecfilt = GetPhotcodeNsecfilt();
    1049   assert(catalog[0].Nsecfilt == Nsecfilt);
    1050 
    1051   if (VERBOSE2) fprintf (stderr, "marking poor measures\n");
    1052   Nmax = 0;
    1053   for (i = 0; i < catalog[0].Naverage; i++) {
    1054     Nmax = MAX (Nmax, catalog[0].average[i].Nmeasure);
    1055   }
    1056 
    1057   ALLOCATE (R, double, Nmax);
    1058   ALLOCATE (D, double, Nmax);
    1059   ALLOCATE (dR, double, Nmax);
    1060   ALLOCATE (dD, double, Nmax);
    1061   ALLOCATE (d2, double, Nmax);
    1062   ALLOCATE (index, double, Nmax);
    1063 
    1064   /* it makes no sense to mark 3-sigma outliers with <5 measurements */
    1065   TOOFEW = MAX (5, SRC_MEAS_TOOFEW);
    1066 
    1067   Ns = CLIP_THRESH;
    1068   Ndel = Nave = 0;
    1069      
    1070   /* loop over each object in the catalog */
    1071   for (j = 0; j < catalog[0].Naverage; j++) {
    1072    
    1073     // pointer to this set of measurements
    1074     m = catalog[0].average[j].measureOffset;
    1075     Measure *measure = &catalog[0].measure[m];
    1076 
    1077     /* accumulate list of valid measurements */
    1078     N = 0;
    1079     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1080 
    1081       // reset flag on each invocation
    1082       measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM;
    1083      
    1084       // skip measurements based on user selected criteria
    1085       if (!MeasFilterTest(&measure[k], FALSE)) continue;
    1086       R[N] = measure[k].R;
    1087       D[N] = measure[k].D;
    1088       dR[N] = GetAstromError(&measure[k], ERROR_MODE_RA);
    1089       dD[N] = GetAstromError(&measure[k], ERROR_MODE_DEC);
    1090       if (isnan(R[N]) || isnan(D[N])) continue;
    1091       N++;
    1092     }
    1093     if (N <= TOOFEW) continue;
    1094    
    1095     /* calculate mean of all points*/
    1096     initstats ("MEAN");
    1097     liststats (R, dR, N, &statsR);
    1098     liststats (D, dD, N, &statsD);
    1099     statsR.sigma = MAX (MIN_ERROR, statsR.sigma);
    1100     statsD.sigma = MAX (MIN_ERROR, statsD.sigma);
    1101    
    1102     /* calculate deviations of all points*/
    1103     N = 0;
    1104     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1105       // skip bad measurements
    1106       if (!MeasFilterTest(&measure[k], FALSE)) continue; 
    1107       x = measure[k].R - statsR.median;
    1108       y = measure[k].D - statsD.median;
    1109       theta = atan2(y,x);
    1110       d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) +
    1111                              SQR(statsD.sigma * Ns * sin(theta)));     
    1112       index[N] = k;
    1113       N++;
    1114     }
    1115    
    1116     // sort d2
    1117     dsortpair(d2, index, N);
    1118     N = (N/2 > (N-1)) ? N/2 : N-1;
    1119 
    1120     // recalculate image center, sigma based on closest 50% of points
    1121     for (k = 0;  k < N; k++) {
    1122       off_t ind = (off_t) index[k];
    1123       R[k] = measure[ind].R;
    1124       D[k] = measure[ind].D;
    1125       dR[k] = GetAstromError(&measure[ind], ERROR_MODE_RA);
    1126       dD[k] = GetAstromError(&measure[ind], ERROR_MODE_DEC);
    1127     }
    1128     liststats (R, dR, N, &statsR);
    1129     liststats (D, dD, N, &statsD);
    1130     statsR.sigma = MAX (MIN_ERROR, statsR.sigma);
    1131     statsD.sigma = MAX (MIN_ERROR, statsD.sigma);
    1132    
    1133     // use these new statistics to flag outliers
    1134     N = 0;
    1135     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1136       //skip bad measurements
    1137       if (!MeasFilterTest(&measure[k], FALSE)) continue; 
    1138       x = measure[k].R - statsR.median;
    1139       y = measure[k].D - statsD.median;
    1140       theta = atan2(y,x);
    1141       d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) +
    1142                              SQR(statsD.sigma * Ns * sin(theta)));     
    1143       if ((d2[N]) > 1) {
    1144         measure[k].dbFlags |= ID_MEAS_POOR_ASTROM;
    1145         Ndel ++;
    1146       }
    1147       N++;
    1148       Nave++;
    1149     }  // done rejecting outliers
    1150 
    1151     // examine results
    1152     // relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, catalog[0].average[j].Nmeasure, statsR, statsD, Ns);
    1153    
    1154   } // done looping over objects
    1155  
    1156   if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave);
    1157   free (R);
    1158   free (dR);
    1159   free (D);
    1160   free (dD);
    1161   free (d2);
    1162   free (index);
    1163 }
    1164 
    1165 /** Determine whether a measurement should be included in the analysis, based on supplied filter criteria */
    1166 // we only optionally apply the sigma limit: for object averages, this should not be used
    1167 int MeasFilterTestTiny(MeasureTiny *measure, int applySigmaLim) {
    1168   int found, k;
    1169   long mask;
    1170   PhotCode *code;
    1171   float mag;
    1172 
    1173   if (!finite(measure[0].R) || !finite(measure[0].D)) return FALSE;
    1174   if (!finite(measure[0].M)) return FALSE; //XXX is this necessary for all relastro tasks?
    1175   if (!finite(measure[0].dM)) return FALSE; //XXX is this necessary for all relastro tasks?
    1176  
    1177   if ((MinBadQF > 0.0) && (isGPC1chip(measure[0].photcode) || isGPC1stack(measure[0].photcode))) {
    1178     if (!isfinite(measure[0].psfQF)) { return FALSE; };
    1179     if (measure[0].psfQF < MinBadQF) { return FALSE; };
    1180   }
    1181 
    1182   /* select measurements by photcode, or equiv photcode, if specified */
    1183   if (NphotcodesKeep > 0) {
    1184     found = FALSE;
    1185     for (k = 0; (k < NphotcodesKeep) && !found; k++) {
    1186       if (photcodesKeep[k][0].code == measure[0].photcode) found = TRUE;
    1187       if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1188     }
    1189     if (!found) return FALSE;
    1190   }
    1191  
    1192   if (NphotcodesSkip > 0) {
    1193     found = FALSE;
    1194     for (k = 0; (k < NphotcodesSkip) && !found; k++) {
    1195       if (photcodesSkip[k][0].code == measure[0].photcode) found = TRUE;
    1196       if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1197     }
    1198     if (found) return FALSE;
    1199   } 
    1200  
    1201   /* select measurements by time */
    1202   if (TimeSelect) {
    1203     if (measure[0].t < TSTART) return FALSE;
    1204     if (measure[0].t > TSTOP) return FALSE;
    1205   }
    1206  
    1207   /* select measurements by quality */
    1208   if (PhotFlagSelect) {
    1209     if (PhotFlagBad) {
    1210       mask = PhotFlagBad;
    1211     } else {
    1212       code = GetPhotcodebyCode (measure[0].photcode);
    1213       if (!code) return FALSE;
    1214       mask = code[0].astromBadMask;
    1215     }
    1216     if (mask & measure[0].photFlags) return FALSE;
    1217   }
    1218 
    1219   /* select measurements by measurement error */
    1220   // this is a bit convoluted: applySigmaLim is only TRUE when this function is
    1221   // called by bcatalog.  for UpdateObjects, it is FALSE
    1222   if (applySigmaLim && (SIGMA_LIM > 0) && (measure[0].dM > SIGMA_LIM)) {
    1223     return FALSE;
    1224   }
    1225  
    1226   /* select measurements by mag limit */
    1227   if (ImagSelect) {
    1228     mag = PhotInstTiny (measure, MAG_CLASS_PSF);
    1229     if (mag < ImagMin || mag > ImagMax) return FALSE;
    1230   }
    1231  
    1232   return TRUE;
    1233 }
    1234 
    1235 # define SUPER_VERBOSE 0
    1236 
    1237 /** Determine whether a measurement should be included in the analysis, based on supplied filter criteria */
    1238 // we only optionally apply the sigma limit: for object averages, this should not be used (should it?)
    1239 int MeasFilterTest(Measure *measure, int applySigmaLim) {
    1240   int found, k;
    1241   long mask;
    1242   PhotCode *code;
    1243   float mag;
    1244 
    1245   if (!finite(measure[0].R) || !finite(measure[0].D)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 1\n"); return FALSE; };
    1246   if (!finite(measure[0].M)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 2\n"); return FALSE; }; //XXX is this necessary for all relastro tasks?
    1247   if (!finite(measure[0].dM)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 3\n"); return FALSE; }; //XXX is this necessary for all relastro tasks?
    1248  
    1249   /* select measurements by photcode, or equiv photcode, if specified */
    1250   if (NphotcodesKeep > 0) {
    1251     found = FALSE;
    1252     for (k = 0; (k < NphotcodesKeep) && !found; k++) {
    1253       if (photcodesKeep[k][0].code == measure[0].photcode) found = TRUE;
    1254       if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1255     }
    1256     if (!found) { if (SUPER_VERBOSE) fprintf (stderr, "filter 4\n"); return FALSE; };
    1257   }
    1258  
    1259   if (NphotcodesSkip > 0) {
    1260     found = FALSE;
    1261     for (k = 0; (k < NphotcodesSkip) && !found; k++) {
    1262       if (photcodesSkip[k][0].code == measure[0].photcode) found = TRUE;
    1263       if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1264     }
    1265     if (found) { if (SUPER_VERBOSE) fprintf (stderr, "filter 5\n"); return FALSE; };
    1266   } 
    1267  
    1268   if ((MinBadQF > 0.0) && isGPC1chip(measure[0].photcode)) {
    1269     if (!isfinite(measure[0].psfQF)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 6\n"); return FALSE; };
    1270     if (measure[0].psfQF < MinBadQF) { if (SUPER_VERBOSE) fprintf (stderr, "filter 7\n"); return FALSE; };
    1271   }
    1272 
    1273   /* select measurements by time */
    1274   if (TimeSelect) {
    1275     if (measure[0].t < TSTART) { if (SUPER_VERBOSE) fprintf (stderr, "filter 8\n"); return FALSE; };
    1276     if (measure[0].t > TSTOP) { if (SUPER_VERBOSE) fprintf (stderr, "filter 9\n"); return FALSE; };
    1277   }
    1278  
    1279   /* select measurements by quality */
    1280   if (PhotFlagSelect) {
    1281     if (PhotFlagBad) {
    1282       mask = PhotFlagBad;
    1283     } else {
    1284       code = GetPhotcodebyCode (measure[0].photcode);
    1285       if (!code) { if (SUPER_VERBOSE) fprintf (stderr, "filter 10\n"); return FALSE; };
    1286       mask = code[0].astromBadMask;
    1287     }
    1288     if (mask & measure[0].photFlags) { if (SUPER_VERBOSE) fprintf (stderr, "filter 11\n"); return FALSE; };
    1289   }
    1290 
    1291   /* select measurements by measurement error */
    1292   if (applySigmaLim && (SIGMA_LIM > 0) && (measure[0].dM > SIGMA_LIM)) {
    1293     { if (SUPER_VERBOSE) fprintf (stderr, "filter 12\n"); return FALSE; };
    1294   }
    1295  
    1296   /* select measurements by mag limit */
    1297   if (ImagSelect) {
    1298     mag = PhotInst (measure, MAG_CLASS_PSF);
    1299     if (mag < ImagMin || mag > ImagMax) { if (SUPER_VERBOSE) fprintf (stderr, "filter 13\n"); return FALSE; };
    1300   }
    1301  
    1302   return TRUE;
    1303 }
    1304 # endif
  • trunk/Ohana/src/relastro/src/StarMaps.c

    r39457 r39926  
    166166  dLmax = dMmax = 0.0;
    167167
     168  float plateScale;
     169  if (images[N].coords.mosaic) {
     170    // NOTE: for the full pixel to sky plate scale, use this:
     171    // float plateScaleX = 3600.0*images[N].coords.mosaic->cdelt1*images[N].coords.cdelt1;
     172    // float plateScaleY = 3600.0*images[N].coords.mosaic->cdelt2*images[N].coords.cdelt2;
     173
     174    // since we are compare L,M values, just need to compensate for focal plate to sky:
     175    float plateScaleX = 3600.0*fabs(images[N].coords.mosaic->cdelt1);
     176    float plateScaleY = 3600.0*fabs(images[N].coords.mosaic->cdelt2);
     177    plateScale = 0.5*(plateScaleX + plateScaleY);
     178  } else {
     179    // since we are compare L,M values, just need to compensate for arcsec vs degrees:
     180    plateScale = 3600.0;
     181  }
     182
    168183  for (i = 0; i < starmap[N].Npoints; i++) {
    169184
     
    171186    XY_to_LM (&L, &M, starmap[N].points[i].X, starmap[N].points[i].Y, &images[N].coords);
    172187
    173     starmap[N].points[i].dL = starmap[N].points[i].L - L;
    174     starmap[N].points[i].dM = starmap[N].points[i].M - M;
     188    starmap[N].points[i].dL = plateScale*(starmap[N].points[i].L - L);
     189    starmap[N].points[i].dM = plateScale*(starmap[N].points[i].M - M);
    175190
    176191    dLmax = MAX(fabs(starmap[N].points[i].dL), dLmax);
  • trunk/Ohana/src/relastro/src/UpdateChips.c

    r39457 r39926  
    4242  AstromErrorSetLoop (Nloop, TRUE);
    4343
     44  // if ChipMapLoop or ChipOrderLoop is set use that to define the value of CHIPMAP and/or CHIPORDER this loop
     45  if (ChipMapLoop) { CHIPMAP = ChipMapLoop[Nloop]; }
     46  if (ChipOrderLoop) { CHIPORDER = ChipOrderLoop[Nloop]; }
     47 
    4448  if (NTHREADS) {
    4549    UpdateChips_threaded (catalog, Ncatalog);
     
    6064  for (i = 0; i < Nimage; i++) {
    6165
    62     VERBOSE_IMAGE = !strcmp(image[i].name, "o5745g0516o.356887.cm.982631.smf[XY54]");
     66    VERBOSE = FALSE;
     67    VERBOSE_IMAGE |= !strcmp(image[i].name, "o5745g0516o.356887.cm.982631.smf[XY45]");
     68    VERBOSE_IMAGE |= !strcmp(image[i].name, "o5745g0526o.356899.cm.982643.smf[XY45]");
     69    VERBOSE_IMAGE |= !strcmp(image[i].name, "o5748g0436o.358811.cm.982690.smf[XY34]");
    6370
    6471    // XXX looks like everything below is thread safe : we can unroll this into a set of
    6572    // helper functions that grab the next available chip....
    6673
     74    // allow certain cameras to stay static
     75    if (SKIP_PS1_CHIP  && isGPC1chip (image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     76    if (SKIP_PS1_STACK && isGPC1stack(image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     77    if (SKIP_HSC       && isHSCchip  (image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     78    if (SKIP_CFH       && isCFHchip  (image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     79   
    6780    /* skip all except WRP images */
    6881    if (strcmp(&image[i].coords.ctype[4], "-WRP")) {
     
    160173    setImageRaw (catalog, Ncatalog, i, raw, Nraw, MODE_MOSAIC);
    161174    if (USE_GALAXY_MODEL) {
    162       // XXX DEPRECATE?
     175      // the image calibration was calculated using a galaxy motion model
    163176      image[i].flags |= ID_IMAGE_ASTROM_GMM;
    164177    }
     
    281294    }
    282295
     296    // allow certain cameras to stay static
     297    if (SKIP_PS1_CHIP  && isGPC1chip (image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     298    if (SKIP_PS1_STACK && isGPC1stack(image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     299    if (SKIP_HSC       && isHSCchip  (image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     300    if (SKIP_CFH       && isCFHchip  (image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     301   
    283302    /* skip all except WRP images */
    284303    if (strcmp(&image[i].coords.ctype[4], "-WRP")) {
  • trunk/Ohana/src/relastro/src/UpdateMeasures.c

    r39624 r39926  
    115115
    116116      // only modify the chip coordinates
    117       if (isGPC1chip (measureT->photcode)) {
     117      if (UPDATE_PS1_STACK_MEASURE && isGPC1stack (measureT->photcode)) {
     118        measureT->R = R;
     119        measureT->D = D;
     120        if (measureB) {
     121          measureB->R = R;
     122          measureB->D = D;
     123        }
     124      }
     125      // only modify the chip coordinates
     126      if (UPDATE_PS1_CHIP_MEASURE && isGPC1chip (measureT->photcode)) {
     127        measureT->R = R;
     128        measureT->D = D;
     129        if (measureB) {
     130          measureB->R = R;
     131          measureB->D = D;
     132        }
     133      }
     134      // only modify the chip coordinates
     135      if (UPDATE_HSC_MEASURE && isGPC1chip (measureT->photcode)) {
     136        measureT->R = R;
     137        measureT->D = D;
     138        if (measureB) {
     139          measureB->R = R;
     140          measureB->D = D;
     141        }
     142      }
     143      // only modify the chip coordinates
     144      if (UPDATE_CFH_MEASURE && isGPC1chip (measureT->photcode)) {
    118145        measureT->R = R;
    119146        measureT->D = D;
  • trunk/Ohana/src/relastro/src/UpdateObjectOffsets.c

    r39693 r39926  
    167167    strextend (&command, "relastro_client -update-offsets");
    168168    strextend (&command, "-hostID %d", group->hosts[i][0].hostID);
     169    strextend (&command, "-hostdir %s", group->hosts[i][0].pathname);
     170
    169171    strextend (&command, "-D CATDIR %s", CATDIR);
    170     strextend (&command, "-hostdir %s", group->hosts[i][0].pathname);
    171172    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    172173    strextend (&command, "-statmode %s", STATMODE);
    173174    strextend (&command, "-minerror %f", MIN_ERROR);
    174175
     176    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     177    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     178
    175179    if (FIT_MODE == FIT_PM_ONLY)         strextend (&command, "-pm");
    176180    if (FIT_MODE == FIT_PAR_ONLY)        strextend (&command, "-par");
     
    180184    if (VERBOSE2)      strextend (&command, "-vv");
    181185    if (RESET)         strextend (&command, "-reset");
    182     if (UPDATE)        strextend (&command, "-update");
    183 
    184     if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
    185186
    186187    if (ImagSelect)    strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    187188    if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue);
    188    
    189     if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
    190189    if (FlagOutlier)     strextend (&command, "-clip %d", CLIP_THRESH);
    191190    if (ExcludeBogus)    strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    192191   
    193     if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
    194192    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
    195 
    196     if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
    197     if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
    198 
    199193    if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
    200194    if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
     
    204198    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    205199
    206     if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    207 
    208200    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    209201      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     
    213205    }
    214206
     207    if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
     208    if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
     209
     210    if (UPDATE_PS1_STACK_MEASURE) strextend (&command, "-update-ps1-stack");
     211    if (UPDATE_PS1_CHIP_MEASURE) strextend (&command, "-update-ps1-chip");
     212    if (UPDATE_HSC_MEASURE)      strextend (&command, "-update-hsc");
     213    if (UPDATE_CFH_MEASURE)      strextend (&command, "-update-cfh");
     214
     215    if (UPDATE)        strextend (&command, "-update");
     216    if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
     217    if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
     218    if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     219
    215220    if (MinBadQF > 0.0)        strextend (&command, "-min-bad-psfqf %f", MinBadQF);
    216221    if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset  %f", MaxMeanOffset);
     222    if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    217223
    218224    if (TimeSelect) {
     
    300306    strextend (&command, "relastro_client -update-offsets");
    301307    strextend (&command, "-hostID %d", table->hosts[i].hostID);
     308    strextend (&command, "-hostdir %s", table->hosts[i].pathname);
     309
    302310    strextend (&command, "-D CATDIR %s", CATDIR);
    303     strextend (&command, "-hostdir %s", table->hosts[i].pathname);
    304311    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    305312    strextend (&command, "-statmode %s", STATMODE);
    306313    strextend (&command, "-minerror %f", MIN_ERROR);
    307314
     315    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     316    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     317
    308318    if (FIT_MODE == FIT_PM_ONLY)         strextend (&command, "-pm");
    309319    if (FIT_MODE == FIT_PAR_ONLY)        strextend (&command, "-par");
     
    313323    if (VERBOSE2)      strextend (&command, "-vv");
    314324    if (RESET)         strextend (&command, "-reset");
    315     if (UPDATE)        strextend (&command, "-update");
    316 
    317     if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
    318325
    319326    if (ImagSelect)    strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    320327    if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue);
    321    
    322     if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
    323328    if (FlagOutlier)     strextend (&command, "-clip %d", CLIP_THRESH);
    324329    if (ExcludeBogus)    strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    325330   
    326     if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
    327331    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
    328 
    329     if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
    330     if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
    331 
    332332    if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
    333333    if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
     
    337337    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    338338
    339     if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    340 
    341339    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    342340      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     
    345343      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
    346344    }
     345
     346    if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
     347    if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
     348
     349    if (UPDATE_PS1_STACK_MEASURE) strextend (&command, "-update-ps1-stack");
     350    if (UPDATE_PS1_CHIP_MEASURE) strextend (&command, "-update-ps1-chip");
     351    if (UPDATE_HSC_MEASURE)      strextend (&command, "-update-hsc");
     352    if (UPDATE_CFH_MEASURE)      strextend (&command, "-update-cfh");
     353
     354    if (UPDATE)        strextend (&command, "-update");
     355    if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
     356    if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
     357    if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     358
     359    if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    347360
    348361    if (MinBadQF > 0.0)        strextend (&command, "-min-bad-psfqf %f", MinBadQF);
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r39617 r39926  
    55# define PAR_MIN_NPTS 7
    66# define PAR_MIN_NPTS_BOOT 6
    7 # define PM_MIN_NPTS 4
    8 # define PM_MIN_NPTS_BOOT 3
    9 # define POS_MIN_NPTS 3
    10 # define POS_MIN_NPTS_BOOT 2
     7# define PM_MIN_NPTS 5
     8# define PM_MIN_NPTS_BOOT 4
     9# define POS_MIN_NPTS 4
     10# define POS_MIN_NPTS_BOOT 4
    1111
    1212typedef enum {
    13   SELECT_MEAS_HAS_DATA  = 1,
    14   SELECT_MEAS_HAS_STACK = 2,
    15   SELECT_MEAS_HAS_2MASS = 4,
     13  SELECT_MEAS_HAS_DATA  = 0x01,
     14  SELECT_MEAS_HAS_STACK = 0x02,
     15  SELECT_MEAS_HAS_2MASS = 0x04,
     16  SELECT_MEAS_HAS_GAIA  = 0x08,
     17  SELECT_MEAS_HAS_TYCHO = 0x10,
    1618} SelectMeasureStatus;
    1719
     
    181183    if (Trange < PM_DT_MIN) {
    182184      // not enough baseline for proper motion, only set mean position
    183       mode = FIT_AVERAGE;
    184185      goto justPosition;
    185186    }
    186187    if (parRange < PAR_FACTOR_MIN) {
    187188      // not enough parallax factor range, skip parallax
    188       mode = FIT_PM_ONLY;
    189189      goto skipParallax;
    190190    }
    191191    if (fitStats->Npoints < PAR_MIN_NPTS) {
    192192      // not enough data, skip parallax
    193       mode = FIT_PM_ONLY;
    194193      goto skipParallax;
    195194    }
    196195
    197196    // we are going to use the IRLS analysis to calculate the mean solution and the masking
    198     // then run N_BOOTSTRAP_SAMPLES to measure the errors
    199     fitStats->fitdataPar->getError = !N_BOOTSTRAP_SAMPLES;
    200     if (!FitPMandPar_IRLS (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints)) {
    201       mode = FIT_PM_ONLY;
    202       goto skipParallax;
    203     }
    204 
    205     if (N_BOOTSTRAP_SAMPLES) {
     197    // then run N_BOOTSTRAP_SAMPLES to measure the errors.  We first measure the OLS error,
     198    // and choose the max of the OLS and bootstrap errors
     199    fitStats->fitdataPar->getError = TRUE;
     200    if (USE_IRLS) {
     201      if (!FitPMandPar_IRLS (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints)) {
     202        goto skipParallax;
     203      }
     204    } else {
     205      if (!FitPMandPar_Basic (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints)) {
     206        goto skipParallax;
     207      }
     208    }
     209
     210    // in the fits above, we have saved the formal error for the unmasked points. 
     211    // if we do not have enough points for bootstrap, we will keep those errors
     212    if (N_BOOTSTRAP_SAMPLES && (fitPar.Nfit >= PAR_MIN_NPTS_BOOT)) {
    206213      fitStats->Nfit = 0;
    207214      int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
    208       if (Nnomask < PAR_MIN_NPTS_BOOT) {
    209         // if we do not have enough points to assess parallax error, we cannot do the bootstrap analysis.
    210         mode = FIT_PM_ONLY;
    211         goto skipParallax;
    212       }
     215
     216      // if we do not have enough points to assess parallax error, skip the bootstrap analysis.
     217      // (I think the test above means we never do this skip)
     218      if (Nnomask < PAR_MIN_NPTS_BOOT) goto skipParallaxBootstrap;
     219
    213220      for (k = 0; k < fitStats->NfitAlloc; k++) {
    214221        BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
     
    216223        fitStats->Nfit ++;
    217224      }
    218       // these calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     225
     226      // These calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     227      // this call expects the fitted parameters to have the formal error set: it will apply the
     228      // max of the formal and bootstrap errors
    219229      BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
    220230      BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
     
    224234    }
    225235
     236  skipParallaxBootstrap:
    226237    // project Ro, Do back to RA,DEC
    227238    XY_to_RD (&fitPar.Ro, &fitPar.Do, fitPar.Ro, fitPar.Do, &fitStats->coords);
     
    242253    valid = valid && (fabs(fitPar.uD) < 4.0);
    243254    valid = valid && (fabs(fitPar.p) < 2.0);
    244     if (!valid) {
    245       mode = FIT_PM_ONLY;
    246     } else {
     255    if (valid) {
    247256      average[0].flags |= ID_OBJ_USE_PAR;
    248257    }
     
    254263  if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) {
    255264    if (Trange < PM_DT_MIN) {
    256       mode = FIT_AVERAGE;
    257265      goto justPosition;
    258266    }
    259267    if (fitStats->Npoints < PM_MIN_NPTS) {
    260       mode = FIT_AVERAGE;
    261268      goto justPosition;
    262269    }
    263270
    264271    // if we have fitted (and accepted) a parallax model, get the best pm fit and chisq
    265     // given the set of points (mask is respected)
    266     if (average[0].flags & ID_OBJ_USE_PAR) {
     272    // given the set of points (mask is respected).  Alternatively, if we do not request
     273    // IRLS fitting, the just use OLS fitting (skip bootstrap)
     274    if ((average[0].flags & ID_OBJ_USE_PAR) || !USE_IRLS) {
    267275      if (!FitPM_Basic (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
    268276        average[0].flags |= ID_OBJ_BAD_PM;
    269277        goto justPosition;
    270278      }
    271     } else {
    272       fitStats->fitdataPM->getError = !N_BOOTSTRAP_SAMPLES;
    273       if (!FitPM_IRLS (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
    274         mode = FIT_AVERAGE;
    275         goto justPosition;
    276       }
    277       if (N_BOOTSTRAP_SAMPLES) {
    278         fitStats->Nfit = 0;
    279         int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
    280         if (Nnomask < PM_MIN_NPTS_BOOT) {
    281           mode = FIT_AVERAGE;
    282           goto justPosition;
    283         }
    284         for (k = 0; k < fitStats->NfitAlloc; k++) {
    285           BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
    286           if (!FitPM_Basic (&fitStats->fit[k], fitStats->fitdataPM, fitStats->sample, Nnomask)) continue;
    287           fitStats->Nfit ++;
    288         }
    289         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
    290         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
    291         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR);
    292         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD);
    293       }
    294     }
    295 
     279      goto skipProperMotionBootstrap;
     280    }
     281
     282    // we are going to use the IRLS analysis to calculate the mean solution and the masking
     283    // then run N_BOOTSTRAP_SAMPLES to measure the errors.  We first measure the OLS error,
     284    // and choose the max of the OLS and bootstrap errors
     285    fitStats->fitdataPM->getError = TRUE;
     286    if (!FitPM_IRLS (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
     287      goto justPosition;
     288    }
     289
     290    // in the fits above, we have saved the formal error for the unmasked points. 
     291    // if we do not have enough points for bootstrap, we will keep those errors
     292    if (N_BOOTSTRAP_SAMPLES && (fitPM.Nfit >= PM_MIN_NPTS_BOOT)) {
     293      fitStats->Nfit = 0;
     294      int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
     295       
     296      // if we do not have enough points to assess p.m. error, skip the bootstrap analysis.
     297      // (I think the test above means we never do this skip)
     298      if (Nnomask < PM_MIN_NPTS_BOOT) goto skipProperMotionBootstrap;
     299
     300      for (k = 0; k < fitStats->NfitAlloc; k++) {
     301        BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
     302        if (!FitPM_Basic (&fitStats->fit[k], fitStats->fitdataPM, fitStats->sample, Nnomask)) continue;
     303        fitStats->Nfit ++;
     304      }
     305
     306      // These calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     307      // this call expects the fitted parameters to have the formal error set: it will apply the
     308      // max of the formal and bootstrap errors
     309      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
     310      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
     311      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR);
     312      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD);
     313    }
     314
     315skipProperMotionBootstrap:
    296316    // project Ro, Do back to RA,DEC
    297317    XY_to_RD (&fitPM.Ro, &fitPM.Do, fitPM.Ro, fitPM.Do, &fitStats->coords);
     
    300320    fitStats->Npm ++;
    301321
     322    // XXX a hard-wired hack...
    302323    // unless there is a clear problems (below) with the proper-motion fit or we have a parallax fit, we will use pm fit
    303324    int valid = TRUE;
     
    309330    valid = valid && (fabs(fitPM.uD) < 4.0);
    310331    if (!valid) {
    311       mode = FIT_AVERAGE;
    312332      average[0].flags |= ID_OBJ_BAD_PM;
    313333    } else {
     
    323343    // if we only have one point, this is silly...
    324344
     345    // set the proper motion (to the galaxy model or average value, if desired; else to 0,0)
    325346    FitAstromResultSetPM (&fitPos, 1, average);
    326     // fprintf (stderr, "fit 1: %f %f : %f %f\n", fitPos.Ro, fitPos.Do, fitPos.uR, fitPos.uD);
    327     if (average[0].flags & (ID_OBJ_USE_PAR | ID_OBJ_USE_PM)) {
     347
     348    // if we already have a valid fit (pm or par), use OLS to fit the position
     349    // alternatively, if we do not request IRLS, use OLS
     350    // alternatively, if we do not have enough points, use OLS
     351    if ((average[0].flags & (ID_OBJ_USE_PAR | ID_OBJ_USE_PM)) || (fitStats->Npoints < POS_MIN_NPTS) || !USE_IRLS) {
    328352      if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    329         // if this fails, stick with the PM and/or PAR fit from above
     353        // if this fails, stick with the PM and/or PAR fit from above, or use a single value
    330354        goto doneWithFit;
    331355      }
    332     } else {
    333       if (fitStats->Npoints < POS_MIN_NPTS) {
    334         // I will not try to outlier-reject, just calculate the weighted average
    335         if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    336           // if we have tried this, we have not masked any points; we will find a single unmasked point below
    337           goto doneWithFit;
    338         }
     356      // if we have not already gotten a good fit, use this fit
     357      if (!(average[0].flags & (ID_OBJ_USE_PAR | ID_OBJ_USE_PM))) {
    339358        average[0].flags |= ID_OBJ_USE_AVE;
    340359        average[0].flags |= ID_OBJ_RAW_AVE;
    341         goto useBasic;
    342       }
    343       if (!FitPosPMfixed_IRLS (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    344         // if the above fails, we need to clear the masks and try again below
    345         FitPointsClearMasks (fitStats->points, fitStats->Npoints);
    346         // just calculate the weighted average
    347         if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    348           // if this fails, find a single unmasked point below
    349           goto doneWithFit;
    350         }
    351         average[0].flags |= ID_OBJ_USE_AVE;
    352         average[0].flags |= ID_OBJ_RAW_AVE;
    353         goto useBasic;
    354       }
    355       // fprintf (stderr, "fit 2: %f %f : %f %f\n", fitPos.Ro, fitPos.Do, fitPos.uR, fitPos.uD);
    356       if (N_BOOTSTRAP_SAMPLES) {
    357         fitStats->Nfit = 0;
    358         int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
    359         if (Nnomask < POS_MIN_NPTS_BOOT) {
    360           // if the above fails, we need to clear the masks and try again below
    361           FitPointsClearMasks (fitStats->points, fitStats->Npoints);
    362           if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    363             // if this fails, find a single unmasked point below
    364             goto doneWithFit;
    365           }
    366           average[0].flags |= ID_OBJ_USE_AVE;
    367           average[0].flags |= ID_OBJ_RAW_AVE;
    368           goto useBasic;
    369         }
    370         FitAstromResultSetPM (fitStats->fit, fitStats->NfitAlloc, average);
    371         for (k = 0; k < fitStats->NfitAlloc; k++) {
    372           BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
    373           if (!FitPosPMfixed_Basic (&fitStats->fit[k], fitStats->fitdataPos, fitStats->sample, Nnomask)) continue;
    374           fitStats->Nfit ++;
    375         }
    376         BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
    377         BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
     360      }
     361      goto useBasic;
     362    }
     363   
     364    // try the IRLS fitting, otherwise give up and use OLS
     365    if (!FitPosPMfixed_IRLS (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
     366      // if the above fails, we need to clear the masks and try again below
     367      FitPointsClearMasks (fitStats->points, fitStats->Npoints);
     368      // just calculate the weighted average
     369      if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
     370        // if this fails, find a single unmasked point below
     371        goto doneWithFit;
    378372      }
    379373      average[0].flags |= ID_OBJ_USE_AVE;
     374      average[0].flags |= ID_OBJ_RAW_AVE;
     375      goto useBasic;
     376    }
     377    average[0].flags |= ID_OBJ_USE_AVE;
     378
     379    if (N_BOOTSTRAP_SAMPLES && (fitPos.Nfit >= POS_MIN_NPTS_BOOT)) {
     380      fitStats->Nfit = 0;
     381      int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
     382     
     383      if (Nnomask < POS_MIN_NPTS_BOOT) goto useBasic;
     384     
     385      FitAstromResultSetPM (fitStats->fit, fitStats->NfitAlloc, average);
     386      for (k = 0; k < fitStats->NfitAlloc; k++) {
     387        BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
     388        if (!FitPosPMfixed_Basic (&fitStats->fit[k], fitStats->fitdataPos, fitStats->sample, Nnomask)) continue;
     389        fitStats->Nfit ++;
     390      }
     391     
     392      // These calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     393      // this call expects the fitted parameters to have the formal error set: it will apply the
     394      // max of the formal and bootstrap errors
     395      BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
     396      BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
    380397    }
    381398
     
    544561  average[0].dP         = fit.dp; // parallax error in arcsec
    545562
     563
    546564  average[0].ChiSqAve   = fitPos.chisq;
    547565  average[0].ChiSqPM    = fitPM.chisq;
     
    666684
    667685  int has2MASS = FALSE;
     686  int hasGAIA  = FALSE;
     687  int hasTycho = FALSE;
    668688  int hasStack = FALSE;
    669689  if (stackEntry) *stackEntry = -1;
     
    774794    Npoints++;
    775795
    776     if ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013)) {
    777       has2MASS = TRUE;
    778     }
     796    hasGAIA  =  (measure[k].photcode == 1030);
     797    has2MASS = ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013));
     798    hasTycho = ((measure[k].photcode >= 2020) && (measure[k].photcode <= 2021));
    779799
    780800    myAssert (Npoints <= fit->NpointsAlloc, "oops");
     
    796816      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_2MASS;
    797817    }
     818    if (hasGAIA) {
     819      measure[k].dbFlags |=  ID_MEAS_OBJECT_HAS_GAIA;
     820    } else {
     821      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_GAIA;
     822    }
     823    if (hasTycho) {
     824      measure[k].dbFlags |=  ID_MEAS_OBJECT_HAS_TYCHO;
     825    } else {
     826      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_TYCHO;
     827    }
    798828  }
    799829
     
    803833  if (hasStack) status |= SELECT_MEAS_HAS_STACK;
    804834  if (has2MASS) status |= SELECT_MEAS_HAS_2MASS;
     835  if (hasGAIA)  status |= SELECT_MEAS_HAS_GAIA;
     836  if (hasTycho) status |= SELECT_MEAS_HAS_TYCHO;
    805837  return status;
    806838}
     
    822854
    823855  int i;
     856
     857  myAbort ("this should not be called anymore");
    824858
    825859  // add up the chi square for the fit
     
    852886  int i;
    853887
    854   if (USE_GALAXY_MODEL) {
     888  if (APPLY_PROPER_MOTION) {
    855889    for (i = 0; i < Nfit; i++) {
    856       fit[i].uR = average->uRgal;
    857       fit[i].uD = average->uDgal;
     890      if (USE_GALAXY_MODEL) {
     891        fit[i].uR = average->uRgal;
     892        fit[i].uD = average->uDgal;
     893      } else {
     894        fit[i].uR = average->uR;
     895        fit[i].uD = average->uD;
     896      }
    858897    }
    859898  } else {
  • trunk/Ohana/src/relastro/src/UpdateStacks.c

    r39457 r39926  
    33// NOTE: we only measure the systematic floor of the astrometric scatter per stack, no change to the calibration
    44int UpdateStacks (Catalog *catalog, int Ncatalog) {
     5
     6  if (SKIP_PS1_STACK) return TRUE;
    57
    68  off_t Nimage;
     
    4648
    4749    // XXX: I need to convert dLsig, dMsig from degrees to pixels
    48     dLsig *= 3600.0 / 0.25;
    49     dMsig *= 3600.0 / 0.25;
     50    dLsig *= 3600.0;
     51    dMsig *= 3600.0;
    5052
    5153    image[i].dXpixSys = dLsig;
  • trunk/Ohana/src/relastro/src/args.c

    r39693 r39926  
    11# include "relastro.h"
    2 void usage (void);
    3 void usage_client (void);
     2void usage (int argc, char **argv);
     3void usage_client (int argc, char **argv);
    44void usage_merge_source (void);
    55void usage_merge_source_id (char *name);
    66float *ParseLoopWeights (char *rawlist);
     7int *ParseLoopOrder (char *rawlist, int minValue);
    78
    89int args (int argc, char **argv) {
     
    3940    remove_argument (N, &argc, argv);
    4041
    41     if (argc != 1) usage ();
     42    if (argc != 1) usage (argc, argv);
    4243    return TRUE;
    4344  }
     
    7677    remove_argument (N, &argc, argv);
    7778    CHECK_MEASURE_TO_IMAGE = TRUE;
     79  }
     80
     81  // catch-up mode : for a re-run, allow the sync file to be ahead of the desired location:
     82  CATCH_UP = FALSE;
     83  if ((N = get_argument (argc, argv, "-catch-up"))) {
     84    remove_argument (N, &argc, argv);
     85    CATCH_UP = TRUE;
    7886  }
    7987
     
    105113    remove_argument (N, &argc, argv);
    106114    RELASTRO_OP = OP_PARALLEL_IMAGES;
    107     if (N >= argc) usage();
     115    if (N >= argc) usage (argc, argv);
    108116    IMAGE_TABLE = strcreate (argv[N]);
    109117    remove_argument (N, &argc, argv);
    110     if (!REGION_FILE) usage();
     118    if (!REGION_FILE) usage (argc, argv);
    111119  }
    112120
     
    114122    remove_argument (N, &argc, argv);
    115123    RELASTRO_OP = OP_IMAGES;
     124  }
     125
     126  // used to decide if changes to the image parameters get applied to the measures
     127  APPLY_OFFSETS = FALSE;
     128  if ((N = get_argument (argc, argv, "-apply-offsets"))) {
     129    remove_argument (N, &argc, argv);
     130    APPLY_OFFSETS = TRUE;
     131  }
     132
     133  APPLY_PROPER_MOTION = FALSE;
     134  if ((N = get_argument (argc, argv, "-apply-proper-motion"))) {
     135    remove_argument (N, &argc, argv);
     136    APPLY_PROPER_MOTION = TRUE;
     137  }
     138
     139  SKIP_PS1_CHIP = FALSE;
     140  if ((N = get_argument (argc, argv, "-skip-ps1-chip"))) {
     141    remove_argument (N, &argc, argv);
     142    SKIP_PS1_CHIP = TRUE;
     143  }
     144  SKIP_PS1_STACK = FALSE;
     145  if ((N = get_argument (argc, argv, "-skip-ps1-stack"))) {
     146    remove_argument (N, &argc, argv);
     147    SKIP_PS1_STACK = TRUE;
     148  }
     149  SKIP_HSC = FALSE;
     150  if ((N = get_argument (argc, argv, "-skip-hsc"))) {
     151    remove_argument (N, &argc, argv);
     152    SKIP_HSC = TRUE;
     153  }
     154  SKIP_CFH = FALSE;
     155  if ((N = get_argument (argc, argv, "-skip-cfh"))) {
     156    remove_argument (N, &argc, argv);
     157    SKIP_CFH = TRUE;
     158  }
     159
     160  UPDATE_PS1_STACK_MEASURE = FALSE;
     161  if ((N = get_argument (argc, argv, "-update-ps1-stack"))) {
     162    remove_argument (N, &argc, argv);
     163    UPDATE_PS1_STACK_MEASURE = TRUE;
     164  }
     165  UPDATE_PS1_CHIP_MEASURE = FALSE;
     166  if ((N = get_argument (argc, argv, "-update-ps1-chip"))) {
     167    remove_argument (N, &argc, argv);
     168    UPDATE_PS1_CHIP_MEASURE = TRUE;
     169  }
     170  UPDATE_HSC_MEASURE = FALSE;
     171  if ((N = get_argument (argc, argv, "-update-hsc"))) {
     172    remove_argument (N, &argc, argv);
     173    UPDATE_HSC_MEASURE = TRUE;
     174  }
     175  UPDATE_CFH_MEASURE = FALSE;
     176  if ((N = get_argument (argc, argv, "-update-cfh"))) {
     177    remove_argument (N, &argc, argv);
     178    UPDATE_CFH_MEASURE = TRUE;
     179  }
     180  if (RELASTRO_OP == OP_UPDATE_OFFSETS) {
     181    if (!UPDATE_PS1_STACK_MEASURE && !UPDATE_PS1_CHIP_MEASURE && !UPDATE_HSC_MEASURE && !UPDATE_CFH_MEASURE) {
     182      fprintf (stderr, "for -update-offsets, need to select at least one of -update-ps1-stack, -update-ps1-chip, -update-hsc, -update-cfh\n");
     183      exit (2);
     184    }
     185  }
     186  if ((RELASTRO_OP == OP_PARALLEL_IMAGES) || (RELASTRO_OP == OP_IMAGES)) {
     187    if (APPLY_OFFSETS && !UPDATE_PS1_STACK_MEASURE && !UPDATE_PS1_CHIP_MEASURE && !UPDATE_HSC_MEASURE && !UPDATE_CFH_MEASURE) {
     188      fprintf (stderr, "for [-images or -parallel-images] with -apply-offsets, need to select at least one of -update-ps1-stack, -update-ps1-chip, -update-hsc, -update-cfh\n");
     189      exit (2);
     190    }
     191  }
     192
     193  // for fitting objects, this is always the same as 'ALLOW_IRLS' below, but for fitting
     194  // images, this is set to FALSE while doing the fit for the image parameters
     195  USE_IRLS = TRUE; 
     196  ALLOW_IRLS = TRUE;
     197  if ((N = get_argument (argc, argv, "-no-irls"))) {
     198    remove_argument (N, &argc, argv);
     199    USE_IRLS = FALSE;
     200    ALLOW_IRLS = FALSE;
    116201  }
    117202
     
    120205    remove_argument (N, &argc, argv);
    121206    RELASTRO_OP = OP_PARALLEL_REGIONS;
    122     if (!REGION_FILE) usage();
     207    if (!REGION_FILE) usage (argc, argv);
    123208    if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) {
    124209      remove_argument (N, &argc, argv);
     
    128213
    129214  if ((N = get_argument (argc, argv, "-testobj1"))) {
    130     if (N > argc - 3) usage ();
     215    if (N > argc - 3) usage (argc, argv);
    131216    remove_argument (N, &argc, argv);
    132217    OBJ_ID_SRC = strtol(argv[N], &endptr, 0);
    133     if (*endptr) usage ();
     218    if (*endptr) usage (argc, argv);
    134219    remove_argument (N, &argc, argv);
    135220    CAT_ID_SRC = strtol(argv[N], &endptr, 0);
    136     if (*endptr) usage ();
     221    if (*endptr) usage (argc, argv);
    137222    remove_argument (N, &argc, argv);
    138223  }
    139224
    140225  if ((N = get_argument (argc, argv, "-testobj2"))) {
    141     if (N > argc - 3) usage ();
     226    if (N > argc - 3) usage (argc, argv);
    142227    remove_argument (N, &argc, argv);
    143228    OBJ_ID_DST = strtol(argv[N], &endptr, 0);
    144     if (*endptr) usage ();
     229    if (*endptr) usage (argc, argv);
    145230    remove_argument (N, &argc, argv);
    146231    CAT_ID_DST = strtol(argv[N], &endptr, 0);
    147     if (*endptr) usage ();
     232    if (*endptr) usage (argc, argv);
    148233    remove_argument (N, &argc, argv);
    149234  }
     
    167252  if ((N = get_argument (argc, argv, "-high-speed"))) {
    168253    // XXX include a parallax / no-parallax option
    169     if (N >= argc - 4) usage();
     254    if (N >= argc - 4) usage (argc, argv);
    170255    RELASTRO_OP = OP_HIGH_SPEED;
    171256    remove_argument (N, &argc, argv);
     
    181266
    182267  if ((N = get_argument (argc, argv, "-hpm"))) {
    183     if (N >= argc - 2) usage();
     268    if (N >= argc - 2) usage (argc, argv);
    184269    RELASTRO_OP = OP_HPM;
    185270    remove_argument (N, &argc, argv);
     
    212297    FIT_TARGET = TARGET_MOSAICS;
    213298  }
     299  if ((N = get_argument (argc, argv, "-set-chips"))) {
     300    remove_argument (N, &argc, argv);
     301    FIT_TARGET = SET_CHIPS;
     302  }
    214303
    215304  FlagOutlier = FALSE;
     
    231320  }
    232321
    233   if (RELASTRO_OP == OP_NONE) usage();
    234 
    235   if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage();
     322  if (RELASTRO_OP == OP_NONE) usage (argc, argv);
     323
     324  if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage (argc, argv);
    236325
    237326  /* specify portion of the sky : allow default of all sky? */
     
    303392  }
    304393
     394  KEEP_ALL_IMAGES_RA = FALSE;
     395  if ((N = get_argument (argc, argv, "-keep-all-images-ra"))) {
     396    remove_argument (N, &argc, argv);
     397    KEEP_ALL_IMAGES_RA = TRUE;
     398  }
     399
    305400  USE_BASIC_CHECK = FALSE;
    306401  if ((N = get_argument (argc, argv, "-basic-image-search"))) {
     
    315410    remove_argument (N, &argc, argv);
    316411    MaxDensityUse = TRUE;
    317   }
    318 
    319   APPLY_OFFSETS = FALSE;
    320   if ((N = get_argument (argc, argv, "-apply-offsets"))) {
    321     remove_argument (N, &argc, argv);
    322     APPLY_OFFSETS = TRUE;
    323412  }
    324413
     
    439528  }
    440529
    441   CHIPORDER = 0;
    442   if ((N = get_argument (argc, argv, "-chiporder"))) {
    443     remove_argument (N, &argc, argv);
    444     CHIPORDER = atoi(argv[N]);
    445     remove_argument (N, &argc, argv);
    446   }
    447 
    448   CHIPMAP = 0;
    449   if ((N = get_argument (argc, argv, "-chipmap"))) {
    450     remove_argument (N, &argc, argv);
    451     CHIPMAP = atoi(argv[N]);
    452     remove_argument (N, &argc, argv);
    453 
    454   }
    455 
    456530  SAVEPLOT = FALSE;
    457531  PLOTSTUFF = FALSE;
     
    580654  }
    581655
     656  // e.g., -chiporderloop 3,4,5
     657  // NOTE: this must come after -nloop above
     658  ChipOrderLoop = NULL;
     659  ChipOrderLoopStr = NULL;
     660  CHIPORDER = 1;
     661  if ((N = get_argument (argc, argv, "-chiporder"))) {
     662    remove_argument (N, &argc, argv);
     663    CHIPORDER = atoi(argv[N]);
     664    remove_argument (N, &argc, argv);
     665  }
     666  if ((N = get_argument (argc, argv, "-chiporderloop"))) {
     667    remove_argument (N, &argc, argv);
     668    ChipOrderLoopStr = strcreate(argv[N]);
     669    ChipOrderLoop = ParseLoopOrder (argv[N], 1);
     670    remove_argument (N, &argc, argv);
     671  }
     672
     673  ChipMapLoop = NULL;
     674  ChipMapLoopStr = NULL;
     675  CHIPMAP = 0;
     676  if ((N = get_argument (argc, argv, "-chipmap"))) {
     677    remove_argument (N, &argc, argv);
     678    CHIPMAP = atoi(argv[N]);
     679    remove_argument (N, &argc, argv);
     680
     681  }
     682  if ((N = get_argument (argc, argv, "-chipmaploop"))) {
     683    remove_argument (N, &argc, argv);
     684    ChipMapLoopStr = strcreate(argv[N]);
     685    ChipMapLoop = ParseLoopOrder (argv[N], 0);
     686    remove_argument (N, &argc, argv);
     687  }
     688 
     689
    582690  // e.g., -loop-weights-2mass 1000,300,300,200,200,100
    583691  // NOTE: this must come after -nloop above
     
    591699  }
    592700  LoopWeightTycho = NULL;
     701  LoopWeightTychostr = NULL;
    593702  if ((N = get_argument (argc, argv, "-loop-weights-tycho"))) {
    594703    remove_argument (N, &argc, argv);
     
    597706    remove_argument (N, &argc, argv);
    598707  }
     708  LoopWeightGAIA = NULL;
     709  LoopWeightGAIAstr = NULL;
     710  if ((N = get_argument (argc, argv, "-loop-weights-gaia"))) {
     711    remove_argument (N, &argc, argv);
     712    LoopWeightGAIAstr = strcreate(argv[N]);
     713    LoopWeightGAIA = ParseLoopWeights (argv[N]);
     714    remove_argument (N, &argc, argv);
     715  }
     716
     717  GALAXY_MODEL = NULL;
     718  if ((N = get_argument (argc, argv, "-galaxy-model"))) {
     719    remove_argument (N, &argc, argv);
     720    GALAXY_MODEL = strcreate(argv[N]);
     721    remove_argument (N, &argc, argv);
     722  }
     723  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("FEAST-HIPPARCOS");
     724
     725  // for testing, allow the galaxy model scale to be non-unity
     726  TEST_SCALE = 1.0;
     727  if ((N = get_argument (argc, argv, "-testing"))) {
     728    remove_argument (N, &argc, argv);
     729    TEST_SCALE = atof(argv[N]);
     730    remove_argument (N, &argc, argv);
     731  }
    599732
    600733  NTHREADS = 0;
     
    605738  }
    606739
    607   if (argc != 1) usage ();
     740  if (argc != 1) usage (argc, argv);
    608741  return TRUE;
    609742}
     
    614747  FREE (LoopWeight2MASSstr);
    615748  FREE (LoopWeightTychostr);
     749  FREE (LoopWeightGAIAstr);
     750  FREE (LoopWeight2MASS);
     751  FREE (LoopWeightTycho);
     752  FREE (LoopWeightGAIA);
     753
     754  FREE (ChipMapLoop);
     755  FREE (ChipMapLoopStr);
     756  FREE (ChipOrderLoop);
     757  FREE (ChipOrderLoopStr);
    616758
    617759  FREE (PHOTCODE_SKIP_LIST);
     
    628770  FREE (BCATALOG);
    629771  FREE (HOSTDIR);
     772  FREE (GALAXY_MODEL);
    630773
    631774  // these are set in initialize
     
    673816    remove_argument (N, &argc, argv);
    674817  }
    675   if (!HOST_ID) usage_client();
     818  if (!HOST_ID) usage_client (argc, argv);
    676819
    677820  HOSTDIR = NULL;
     
    681824    remove_argument (N, &argc, argv);
    682825  }
    683   if (!HOSTDIR) usage_client();
     826  if (!HOSTDIR) usage_client (argc, argv);
    684827
    685828  if ((N = get_argument (argc, argv, "-load-objects"))) {
     
    726869  }
    727870
     871  SKIP_PS1_CHIP = FALSE;
     872  if ((N = get_argument (argc, argv, "-skip-ps1-chip"))) {
     873    remove_argument (N, &argc, argv);
     874    SKIP_PS1_CHIP = TRUE;
     875  }
     876  SKIP_PS1_STACK = FALSE;
     877  if ((N = get_argument (argc, argv, "-skip-ps1-stack"))) {
     878    remove_argument (N, &argc, argv);
     879    SKIP_PS1_STACK = TRUE;
     880  }
     881  SKIP_HSC = FALSE;
     882  if ((N = get_argument (argc, argv, "-skip-hsc"))) {
     883    remove_argument (N, &argc, argv);
     884    SKIP_HSC = TRUE;
     885  }
     886  SKIP_CFH = FALSE;
     887  if ((N = get_argument (argc, argv, "-skip-cfh"))) {
     888    remove_argument (N, &argc, argv);
     889    SKIP_CFH = TRUE;
     890  }
     891
     892  UPDATE_PS1_STACK_MEASURE = FALSE;
     893  if ((N = get_argument (argc, argv, "-update-ps1-stack"))) {
     894    remove_argument (N, &argc, argv);
     895    UPDATE_PS1_STACK_MEASURE = TRUE;
     896  }
     897  UPDATE_PS1_CHIP_MEASURE = FALSE;
     898  if ((N = get_argument (argc, argv, "-update-ps1-chip"))) {
     899    remove_argument (N, &argc, argv);
     900    UPDATE_PS1_CHIP_MEASURE = TRUE;
     901  }
     902  UPDATE_HSC_MEASURE = FALSE;
     903  if ((N = get_argument (argc, argv, "-update-hsc"))) {
     904    remove_argument (N, &argc, argv);
     905    UPDATE_HSC_MEASURE = TRUE;
     906  }
     907  UPDATE_CFH_MEASURE = FALSE;
     908  if ((N = get_argument (argc, argv, "-update-cfh"))) {
     909    remove_argument (N, &argc, argv);
     910    UPDATE_CFH_MEASURE = TRUE;
     911  }
     912  if (RELASTRO_OP == OP_UPDATE_OFFSETS) {
     913    if (!UPDATE_PS1_STACK_MEASURE && !UPDATE_PS1_CHIP_MEASURE && !UPDATE_HSC_MEASURE && !UPDATE_CFH_MEASURE) {
     914      fprintf (stderr, "for -update-offsets, need to select at least one of -update-ps1-stack, -update-ps1-chip, -update-hsc, -update-cfh\n");
     915      exit (2);
     916    }
     917  }
     918
    728919  // check for object fitting modes
    729920  if ((N = get_argument (argc, argv, "-pm"))) {
     
    742933  if ((N = get_argument (argc, argv, "-high-speed"))) {
    743934    // XXX include a parallax / no-parallax option
    744     if (N >= argc - 5) usage_client();
     935    if (N >= argc - 5) usage_client (argc, argv);
    745936    RELASTRO_OP = OP_HIGH_SPEED;
    746937    remove_argument (N, &argc, argv);
     
    756947
    757948  if ((N = get_argument (argc, argv, "-hpm"))) {
    758     if (N >= argc - 3) usage();
     949    if (N >= argc - 3) usage_client (argc, argv);
    759950    RELASTRO_OP = OP_HPM;
    760951    remove_argument (N, &argc, argv);
     
    766957
    767958  if ((N = get_argument (argc, argv, "-testobj1"))) {
    768     if (N > argc - 3) usage ();
     959    if (N > argc - 3) usage_client (argc, argv);
    769960    remove_argument (N, &argc, argv);
    770961    OBJ_ID_SRC = strtol(argv[N], &endptr, 0);
    771     if (*endptr) usage ();
     962    if (*endptr) usage_client (argc, argv);
    772963    remove_argument (N, &argc, argv);
    773964    CAT_ID_SRC = strtol(argv[N], &endptr, 0);
    774     if (*endptr) usage ();
     965    if (*endptr) usage_client (argc, argv);
    775966    remove_argument (N, &argc, argv);
    776967  }
    777968
    778969  if ((N = get_argument (argc, argv, "-testobj2"))) {
    779     if (N > argc - 3) usage ();
     970    if (N > argc - 3) usage_client (argc, argv);
    780971    remove_argument (N, &argc, argv);
    781972    OBJ_ID_DST = strtol(argv[N], &endptr, 0);
    782     if (*endptr) usage ();
     973    if (*endptr) usage_client (argc, argv);
    783974    remove_argument (N, &argc, argv);
    784975    CAT_ID_DST = strtol(argv[N], &endptr, 0);
    785     if (*endptr) usage ();
     976    if (*endptr) usage_client (argc, argv);
    786977    remove_argument (N, &argc, argv);
    787978  }
     
    805996  }
    806997
    807   if (RELASTRO_OP == OP_NONE) usage_client();
     998  GALAXY_MODEL = NULL;
     999  if ((N = get_argument (argc, argv, "-galaxy-model"))) {
     1000    remove_argument (N, &argc, argv);
     1001    GALAXY_MODEL = strcreate(argv[N]);
     1002    remove_argument (N, &argc, argv);
     1003  }
     1004  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("FEAST-HIPPARCOS");
     1005
     1006  // for testing, allow the galaxy model scale to be non-unity
     1007  TEST_SCALE = 1.0;
     1008  if ((N = get_argument (argc, argv, "-testing"))) {
     1009    remove_argument (N, &argc, argv);
     1010    TEST_SCALE = atof(argv[N]);
     1011    remove_argument (N, &argc, argv);
     1012  }
     1013
     1014  if (RELASTRO_OP == OP_NONE) usage_client (argc, argv);
    8081015
    8091016  /* specify portion of the sky : allow default of all sky? */
     
    10321239  }
    10331240
    1034   if (argc != 1) usage_client ();
     1241  if (argc != 1) usage_client (argc, argv);
    10351242  return TRUE;
    10361243}
     
    10491256  FREE(HIGH_SPEED_DIR);
    10501257  FREE(BCATALOG);
    1051   FREE (HOSTDIR);
     1258  FREE(HOSTDIR);
     1259  FREE(GALAXY_MODEL);
    10521260
    10531261  // these are set in initialize
     
    10661274}
    10671275
    1068 void usage () {
     1276void usage (int argc, char **argv) {
    10691277  fprintf (stderr, "ERROR: USAGE: relastro -images -update-simple [options]\n");
    10701278  fprintf (stderr, "       OR:    relastro -images -update-chips [options]\n");
     
    11161324  fprintf (stderr, "  -v\n");
    11171325  fprintf (stderr, "  \n");
     1326
     1327  fprintf (stderr, "remaining args: ");
     1328  for (int i = 0; i < argc; i++) {
     1329    fprintf (stderr, "%s ", argv[i]);
     1330  }
     1331  fprintf (stderr, "\n");
     1332
    11181333  exit (2);
    11191334}
    11201335
    1121 void usage_client () {
     1336void usage_client (int argc, char **argv) {
    11221337  fprintf (stderr, "ERROR: USAGE: relastro_client -load\n");
    11231338  fprintf (stderr, "       OR:    relastro_client -update-offsets\n");
     
    11501365  fprintf (stderr, "  -v\n");
    11511366  fprintf (stderr, "  \n");
     1367
     1368  fprintf (stderr, "remaining args: ");
     1369  for (int i = 0; i < argc; i++) {
     1370    fprintf (stderr, "%s ", argv[i]);
     1371  }
     1372  fprintf (stderr, "\n");
     1373
    11521374  exit (2);
    11531375}
     
    11891411  }
    11901412
     1413  // this sets the last loops to match the last value...
    11911414  while (Nloop < NLOOP) {
    11921415    weights[Nloop] = weights[Nloop - 1];
    11931416    Nloop ++;
    11941417  }
     1418
    11951419  return weights;
    11961420}
     1421
     1422int *ParseLoopOrder (char *rawlist, int minValue) {
     1423
     1424  int *orders = NULL;
     1425  ALLOCATE (orders, int, NLOOP);
     1426
     1427  int Nloop = 0;
     1428
     1429  /* parse the comma-separated list of photcodes */
     1430  char *myList = strcreate(rawlist);
     1431  char *list = myList;
     1432  char *entry = NULL;
     1433  char *ptr = NULL;
     1434  while ((Nloop < NLOOP) && ((entry = strtok_r (list, ",", &ptr)) != NULL)) {
     1435    list = NULL; // pass NULL on successive strtok_r calls
     1436
     1437    orders[Nloop] = atoi(entry);
     1438    if (orders[Nloop] < minValue) {
     1439      fprintf (stderr, "order cannot be < %d: %s\n", minValue, rawlist);
     1440      exit (3);
     1441    }
     1442
     1443    Nloop ++;
     1444  }
     1445  free (myList);
     1446
     1447  if (Nloop == 0) {
     1448    fprintf (stderr, "syntax error parsing orders: %s\n", rawlist);
     1449    exit (3);
     1450  }
     1451
     1452  // this sets the last loops to match the last value...
     1453  while (Nloop < NLOOP) {
     1454    orders[Nloop] = orders[Nloop - 1];
     1455    Nloop ++;
     1456  }
     1457
     1458  return orders;
     1459}
  • trunk/Ohana/src/relastro/src/assign_images.c

    r39457 r39926  
    4040
    4141  // register the image array with ImageOps.c for later getimageByID calls
    42   initImages (image, NULL, Nimage);
     42  initImages (image, NULL, Nimage, FALSE);
    4343
    4444  if (VERBOSE) fprintf (stderr, "finding images\n");
     
    7272
    7373  for (j = 0; j < Nimage; j++) {
     74   
     75    // allow certain cameras to stay static
     76    if (SKIP_PS1_CHIP  && isGPC1chip (image[j].photcode)) continue;
     77    if (SKIP_PS1_STACK && isGPC1stack(image[j].photcode)) continue;
     78    if (SKIP_HSC       && isHSCchip  (image[j].photcode)) continue;
     79    if (SKIP_CFH       && isCFHchip  (image[j].photcode)) continue;
    7480   
    7581    /* select images by photcode, or equiv photcode, if specified */
  • trunk/Ohana/src/relastro/src/bcatalog.c

    r39587 r39926  
    7272
    7373  int myNskip1 = 0, myNskip2 = 0, myNskip3 = 0, myNskip4 = 0, myNskip5 = 0, myNskip6 = 0;
     74
     75  int NgaiaObject = 0;
    7476
    7577  /* exclude stars not in range or with too few measurements */
     
    187189      if (isGPC1warp(catalog[0].measure[offset].photcode)) continue;
    188190
     191      // allow certain cameras to stay static
     192      if (SKIP_PS1_CHIP  && isGPC1chip(catalog[0].measure[offset].photcode)) continue;
     193      if (SKIP_PS1_STACK && isGPC1stack(catalog[0].measure[offset].photcode)) continue;
     194      if (SKIP_HSC       && isHSCchip(catalog[0].measure[offset].photcode)) continue;
     195      if (SKIP_CFH       && isCFHchip(catalog[0].measure[offset].photcode)) continue;
     196
    189197      // filter objects based on user supplied criteria, including SIGMA_LIM
    190198      if (!MeasFilterTest(&catalog[0].measure[offset], TRUE)) {
     
    250258      }
    251259
     260      if (catalog[0].measure[offset].photcode == 1030) { NgaiaObject ++; }
     261
    252262      CopyMeasureToTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]);
    253263      // subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset];
     
    281291    }
    282292  }
    283   fprintf (stderr, "skips: %d %d %d %d %d %d\n", myNskip1, myNskip2, myNskip3, myNskip4, myNskip5, myNskip6);
     293  fprintf (stderr, "skips: %d %d %d %d %d %d, Ngaia: %d\n", myNskip1, myNskip2, myNskip3, myNskip4, myNskip5, myNskip6, NgaiaObject);
    284294  REALLOCATE (subcatalog[0].average,  Average,     MAX (Naverage, 1));
    285295  REALLOCATE (subcatalog[0].measureT, MeasureTiny, MAX (Nmeasure, 1));
  • trunk/Ohana/src/relastro/src/extra.c

    r37261 r39926  
    3939  return FALSE;
    4040}
     41
     42// for now (20160925) I need to identify HSC chips explicitly.  generalize in the future
     43int isHSCchip (int photcode) {
     44
     45  if ((photcode >= 20000) && (photcode <= 20111)) return TRUE; // g-band
     46  if ((photcode >= 21000) && (photcode <= 21111)) return TRUE; // r-band
     47  if ((photcode >= 22000) && (photcode <= 22111)) return TRUE; // i-band
     48  if ((photcode >= 23000) && (photcode <= 23111)) return TRUE; // z-band
     49  if ((photcode >= 24000) && (photcode <= 24111)) return TRUE; // y-band
     50
     51  return FALSE;
     52}
     53
     54// for now (20160925) I need to identify CFH chips explicitly.  generalize in the future
     55int isCFHchip (int photcode) {
     56
     57  if ((photcode >= 100) && (photcode <= 152)) return TRUE; // g-band
     58  if ((photcode >= 200) && (photcode <= 252)) return TRUE; // r-band
     59  if ((photcode >= 300) && (photcode <= 352)) return TRUE; // i-band
     60  if ((photcode >= 400) && (photcode <= 452)) return TRUE; // z-band
     61  if ((photcode >= 500) && (photcode <= 552)) return TRUE; // y-band
     62
     63  return FALSE;
     64}
  • trunk/Ohana/src/relastro/src/initialize.c

    r39457 r39926  
    1111  ConfigInit (&argc, argv);
    1212  args (argc, argv);
     13
     14  if (USE_GALAXY_MODEL) {
     15    if (!InitGalaxyModel (GALAXY_MODEL)) {
     16      fprintf (stderr, "failed to init galaxy model %s\n", GALAXY_MODEL);
     17      exit (2);
     18    }
     19  }
    1320
    1421  if (RELASTRO_OP == OP_MERGE_SOURCE) return;
  • trunk/Ohana/src/relastro/src/launch_region_hosts.c

    r39457 r39926  
    8181    strextend (&command, "-region-hosts %s", REGION_FILE);
    8282    strextend (&command, "-region-hostID %d", host->hostID);
     83
    8384    strextend (&command, "-D CATDIR %s", CATDIR);
    8485    strextend (&command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat);
    8586    strextend (&command, "-statmode %s", STATMODE);
    8687    strextend (&command, "-minerror %f", MIN_ERROR);
    87     strextend (&command, "-nloop %d", NLOOP);
    88     strextend (&command, "-threads %d", NTHREADS);
     88
     89    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     90    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     91
     92    strextend (&command, " -D RELASTRO_MIN_DISTANCE_MOD %f",     MIN_DISTANCE_MOD);
     93    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD %f",     MAX_DISTANCE_MOD);
     94    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD_ERR %f", MAX_DISTANCE_MOD_ERR);
     95
     96    strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
     97    strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
     98
     99    strextend (&command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX);
     100    strextend (&command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS);
     101
     102    strextend (&command, "-D USE_ICRF_LOCAL %d",   USE_ICRF_LOCAL);
     103    strextend (&command, "-D USE_ICRF_SHFIT %d",   USE_ICRF_SHFIT);
     104    strextend (&command, "-D USE_ICRF_POLE %d",    USE_ICRF_POLE);
    89105
    90106    switch (FIT_TARGET) {
     
    98114        strextend (&command, "-update-mosaics");
    99115        break;
     116      case SET_CHIPS:
     117        strextend (&command, "-set-chips");
     118        break;
    100119      case TARGET_NONE:
    101120        abort();
     
    105124    if (VERBOSE2)           strextend (&command, "-vv");
    106125    if (RESET)              strextend (&command, "-reset");
     126
     127    if (ImagSelect)         strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
     128    if (MaxDensityUse)      strextend (&command, "-max-density %f", MaxDensityValue);
     129    if (FlagOutlier)        strextend (&command, "-clip %d", CLIP_THRESH);
     130    if (ExcludeBogus)       strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
     131
     132    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
     133    if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
     134    if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
     135    if (PhotFlagSelect)     strextend (&command, "+photflags");
     136    if (PhotFlagBad)        strextend (&command, "+photflagbad %d", PhotFlagBad);
     137    if (PhotFlagPoor)       strextend (&command, "+photflagpoor %d", PhotFlagPoor);
     138
     139    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
     140      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     141    }
     142    if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
     143      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
     144    }
     145
     146    if (TEST_SCALE != 1.0)   strextend (&command, "-testing %f", TEST_SCALE);
     147
     148    if (SKIP_PS1_CHIP)       strextend (&command, "-skip-ps1-chip");
     149    if (SKIP_PS1_STACK)      strextend (&command, "-skip-ps1-stack");
     150    if (SKIP_HSC)            strextend (&command, "-skip-hsc");
     151    if (SKIP_CFH)            strextend (&command, "-skip-cfh");
     152
     153    strextend (&command, "-nloop %d", NLOOP);
     154    strextend (&command, "-threads %d", NTHREADS);
     155   
     156    if (PHOTCODE_RESET_LIST) strextend (&command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST);
     157
    107158    if (UPDATE)             strextend (&command, "-update");
    108159    if (PARALLEL)           strextend (&command, "-parallel");
    109160    if (PARALLEL_MANUAL)    strextend (&command, "-parallel-manual");
    110161    if (PARALLEL_SERIAL)    strextend (&command, "-parallel-serial");
    111     if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
    112     if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
    113     if (PHOTCODE_RESET_LIST) strextend (&command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST);
    114 
    115     if (MaxDensityUse)      strextend (&command, "-max-density %f", MaxDensityValue);
    116     if (ImagSelect)         strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    117     if (ExcludeBogus)       strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    118 
    119     if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    120       strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
    121     }
    122     if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
    123       strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
    124     }
    125 
    126     if (PhotFlagSelect)     strextend (&command, "+photflags");
    127     if (PhotFlagBad)        strextend (&command, "+photflagbad %d", PhotFlagBad);
    128     if (PhotFlagPoor)       strextend (&command, "+photflagpoor %d", PhotFlagPoor);
    129 
     162
     163    strextend (&command, "-chiporder %d", CHIPORDER);
    130164    if (CHIPMAP)            strextend (&command, "-chipmap %d", CHIPMAP);
     165    if (ChipMapLoop)        strextend (&command, "-chipmaploop %s", ChipMapLoopStr);
     166    if (ChipOrderLoop)      strextend (&command, "-chiporderloop %s", ChipOrderLoopStr);
     167
    131168    if (RESET_IMAGES)       strextend (&command, "-reset-images");
    132169
     
    136173    if (LoopWeight2MASS) {  strextend (&command, "-loop-weights-2mass %s", LoopWeight2MASSstr); }
    137174    if (LoopWeightTycho) {  strextend (&command, "-loop-weights-tycho %s", LoopWeightTychostr); }
    138 
    139     strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
    140     strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
    141     strextend (&command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX);
    142     strextend (&command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS);
    143 
    144     strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
    145 
    146     strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
    147     strextend (&command, "-D USE_ICRF_LOCAL %d",   USE_ICRF_LOCAL);
    148     strextend (&command, "-D USE_ICRF_SHFIT %d",   USE_ICRF_SHFIT);
    149     strextend (&command, "-D USE_ICRF_POLE %d",    USE_ICRF_POLE);
    150 
    151     if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
     175    if (LoopWeightGAIA)  {  strextend (&command, "-loop-weights-gaia %s", LoopWeightGAIAstr); }
     176    if (APPLY_PROPER_MOTION) strextend (&command, "-apply-proper-motion");
    152177
    153178    if (TimeSelect) {
  • trunk/Ohana/src/relastro/src/load_catalogs.c

    r39466 r39926  
    178178    strextend (&command, "relastro_client -load-objects %s", table->hosts[i].results);
    179179    strextend (&command, " -hostID %d", table->hosts[i].hostID);
     180    strextend (&command, " -hostdir %s", table->hosts[i].pathname);
     181
    180182    strextend (&command, " -D CATDIR %s", CATDIR);
    181     strextend (&command, " -hostdir %s", table->hosts[i].pathname);
    182183    strextend (&command, " -region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    183184    strextend (&command, " -statmode %s", STATMODE);
    184185    strextend (&command, " -minerror %f", MIN_ERROR);
     186
    185187    strextend (&command, " -D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     188    strextend (&command, " -D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     189
    186190    strextend (&command, " -D RELASTRO_MIN_DISTANCE_MOD %f",     MIN_DISTANCE_MOD);
    187191    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD %f",     MAX_DISTANCE_MOD);
    188192    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD_ERR %f", MAX_DISTANCE_MOD_ERR);
    189193
     194    strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
     195    strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
     196
    190197    if (FIT_MODE == FIT_PM_ONLY)         strextend (&command, "-pm");
    191198    if (FIT_MODE == FIT_PAR_ONLY)        strextend (&command, "-par");
    192199    if (FIT_MODE == FIT_PM_AND_PAR)      strextend (&command, "-pmpar");
    193200
    194     if (VERBOSE)       strextend (&command, "-v");
    195     if (VERBOSE2)      strextend (&command, "-vv");
    196     if (RESET)         strextend (&command, "-reset");
    197     if (ImagSelect)    strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    198     if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue);
    199     if (FlagOutlier)   strextend (&command, "-clip %d", CLIP_THRESH);
    200     if (ExcludeBogus)  strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    201 
    202     if (USE_ICRF_CORRECT) strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
    203     if (USE_GALAXY_MODEL) strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
    204    
    205     if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    206       strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
    207     }
    208     if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
    209       strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
    210     }
    211 
    212     if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     201    if (VERBOSE)             strextend (&command, "-v");
     202    if (VERBOSE2)            strextend (&command, "-vv");
     203    if (RESET)               strextend (&command, "-reset");
     204                             
     205    if (ImagSelect)          strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
     206    if (MaxDensityUse)       strextend (&command, "-max-density %f", MaxDensityValue);
     207    if (FlagOutlier)         strextend (&command, "-clip %d", CLIP_THRESH);
     208    if (ExcludeBogus)        strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
     209
    213210    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
    214211    if (PHOTCODE_KEEP_LIST)  strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
     
    217214    if (PhotFlagBad)         strextend (&command, "+photflagbad %d", PhotFlagBad);
    218215    if (PhotFlagPoor)        strextend (&command, "+photflagpoor %d", PhotFlagPoor);
     216
     217    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
     218      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     219    }
     220    if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
     221      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
     222    }
     223
     224    if (SKIP_PS1_CHIP)       strextend (&command, "-skip-ps1-chip");
     225    if (SKIP_PS1_STACK)      strextend (&command, "-skip-ps1-stack");
     226    if (SKIP_HSC)            strextend (&command, "-skip-hsc");
     227    if (SKIP_CFH)            strextend (&command, "-skip-cfh");
     228
     229    if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     230
    219231    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    220232
     
    282294  CatalogSplitter *catalogs = BrightCatalogSplitInit (Nsecfilt);
    283295
     296  ohana_memstats (TRUE);
     297
    284298  for (i = 0; i < table->Nhosts; i++) {
    285299
     
    296310    free (bcatalog->secfilt);
    297311    free (bcatalog);
     312
     313    ohana_memstats (TRUE);
    298314  }
    299315
     
    320336
    321337  BrightCatalogSplitFree (catalogs);
     338  ohana_memstats (TRUE);
    322339
    323340  return (catalog);
  • trunk/Ohana/src/relastro/src/load_images.c

    r39474 r39926  
    6666  }
    6767
    68   initImages (subset, LineNumber, Nsubset);
     68  initImages (subset, LineNumber, Nsubset, !USE_ALL_IMAGES);
    6969  MARKTIME("  init images: %f sec\n", dtime);
    7070 
  • trunk/Ohana/src/relastro/src/relastro_images.c

    r39580 r39926  
    1616  int finalPassMode = FIT_MODE; // start with the globally-defined fit mode
    1717  FIT_MODE = FIT_AVERAGE;
     18
     19  int RESET_ON_UPDATE = RESET; 
     20  RESET = TRUE; // we need to reset when we load the bright catalog subset
    1821
    1922  /* lock and load the image db table */
     
    6568  // XXX NOTE : for 2mass reset, photcodesKeep should now limit to 2MASS measurements
    6669
     70  USE_IRLS = FALSE;  // do not use IRLS yet -- leads to excessive outlier rejections in the loops
     71
    6772  /* major modes */
    6873  switch (FIT_TARGET) {
     
    9095      break;
    9196
     97    case SET_CHIPS:
     98      // we just want to fit the selected chips to the mean positions
     99      UpdateChips (catalog, Ncatalog, 0);   // measure.X,Y -> R,D, fit image.coords
     100      MARKTIME("update chips: %f sec\n", dtime);
     101
     102      break;
     103
    92104    case TARGET_MOSAICS:
    93105      for (i = 0; i < NLOOP; i++) {
     
    102114  }
    103115
    104   if (!UPDATE) {
    105     freeStarMaps();
    106     gfits_db_free (&db);
    107     ohana_memcheck (VERBOSE);
    108     ohana_memdump (VERBOSE);
    109     exit (0);
    110   }
    111 
    112116  // free the image / measurement pointers
    113117  freeImageBins (Ncatalog);
     
    117121  free (catalog);
    118122  freeMosaics ();
     123
     124  if (!UPDATE) {
     125    freeStarMaps();
     126    dvo_image_unlock (&db);
     127    freeImages (db.ftable.buffer);
     128    gfits_db_free (&db);
     129    return TRUE;
     130  }
    119131
    120132  // If we did NOT use all images, then we applied the measured corrections to a subset of
     
    154166  // iterate over catalogs to make detection coordinates consistant
    155167  if (APPLY_OFFSETS) {
     168    USE_IRLS = ALLOW_IRLS;  // now that we have fitted the images, choose the user's option
     169    RESET = RESET_ON_UPDATE;
    156170    UpdateObjectOffsets (skylist, 0, NULL);
    157171  }
  • trunk/Ohana/src/relastro/src/relastro_objects.c

    r39457 r39926  
    159159    strextend (&command, "relastro_client -update-objects");
    160160    strextend (&command, "-hostID %d", table->hosts[i].hostID);
     161    strextend (&command, "-hostdir %s", table->hosts[i].pathname);
     162
    161163    strextend (&command, "-D CATDIR %s", CATDIR);
    162     strextend (&command, "-hostdir %s", table->hosts[i].pathname);
    163164    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    164165    strextend (&command, "-statmode %s", STATMODE);
     166    strextend (&command, "-minerror %f", MIN_ERROR);
     167
     168    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     169    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
    165170
    166171    if (FIT_MODE == FIT_PM_ONLY)         { strextend (&command, "-pm"); }
     
    171176    if (VERBOSE2)      { strextend (&command, "-vv"); }
    172177    if (RESET)         { strextend (&command, "-reset"); }
    173     if (UPDATE)        { strextend (&command, "-update"); }
     178
    174179    if (ImagSelect)    { strextend (&command, "-instmag %f %f", ImagMin, ImagMax); }
    175180    if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); }
    176181    if (FlagOutlier)   { strextend (&command, "-clip %d", CLIP_THRESH); }
    177 
    178     if (USE_ALL_IMAGES)      { strextend (&command, "-use-all-images"); }
     182    if (ExcludeBogus)    strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
     183
    179184    if (USE_FIXED_PIXCOORDS) { strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); }
    180185    if (PHOTCODE_KEEP_LIST)  { strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); }
     
    185190    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    186191
     192    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
     193      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     194    }
     195    if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
     196      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
     197    }
     198
     199    if (UPDATE)        { strextend (&command, "-update"); }
     200    if (USE_ALL_IMAGES)      { strextend (&command, "-use-all-images"); }
     201
    187202    if (MinBadQF > 0.0)          strextend (&command, "-min-bad-psfqf %f", MinBadQF);
    188203    if (MaxMeanOffset != 10.0)   strextend (&command, "-max-mean-offset  %f", MaxMeanOffset);
  • trunk/Ohana/src/relastro/src/relastro_parallel_images.c

    r39580 r39926  
    6161  initMosaics (image, Nimage);
    6262
    63   initImages (image, NULL, Nimage);
     63  initImages (image, NULL, Nimage, FALSE);
    6464
    6565  SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
     
    103103
    104104  client_logger_message ("starting the loops: %s\n", myHostName);
     105
     106  RESET = TRUE; // we need to reset when we load the bright catalog subset
     107  FIT_MODE = FIT_AVERAGE; // we need to only fit the average
     108  USE_IRLS = FALSE;  // do not use IRLS yet -- leads to excessive outlier rejections in the loops
    105109
    106110  /* major modes */
  • trunk/Ohana/src/relastro/src/select_images.c

    r39474 r39926  
    121121    }
    122122
     123    // allow certain cameras to stay static
     124    if (SKIP_PS1_CHIP  && isGPC1chip (timage[i].photcode)) continue;
     125    if (SKIP_PS1_STACK && isGPC1stack(timage[i].photcode)) continue;
     126    if (SKIP_HSC       && isHSCchip  (timage[i].photcode)) continue;
     127    if (SKIP_CFH       && isCFHchip  (timage[i].photcode)) continue;
     128   
    123129    /* select images by photcode, or equiv photcode, if specified */
    124130    if (NphotcodesKeep > 0) {
     
    187193    if (DmaxImage < DminSkyRegion) continue;
    188194   
     195    if (KEEP_ALL_IMAGES_RA) goto found_it;
     196
    189197    // the sky region RA is defined to be 0 - 360.0
    190198    if (RminImage > RmaxSkyRegion) continue;
  • trunk/Ohana/src/relastro/src/syncfile.c

    r36871 r39926  
    3939    int loop;
    4040    sscanf (message, "%*s %d", &loop);
     41    if (CATCH_UP && (nloop < loop)) return TRUE; // if I am behind this machine, I need to catch up!
    4142    if (loop != nloop) {
    4243      usleep (2000000);
  • trunk/Ohana/src/relphot/include/relphot.h

    r39648 r39926  
    309309int    RESET_ZEROPTS;
    310310int    REPAIR_WARPS;
     311int    PRESERVE_PS1;
    311312int    UPDATE;
    312313int    SAVE_IMAGE_UPDATES;
     
    616617int isTYCHO (int photcode);
    617618
     619int isHSCchip  (int photcode);
     620int isCFHchip  (int photcode);
     621
    618622int magStatsByRanking (StatDataSet *dataset, StatType *stats);
    619623
  • trunk/Ohana/src/relphot/src/args.c

    r39642 r39926  
    226226    remove_argument (N, &argc, argv);
    227227    REPAIR_WARPS = TRUE;
     228  }
     229
     230  PRESERVE_PS1 = FALSE;
     231  if ((N = get_argument (argc, argv, "-preserve-ps1"))) {
     232    remove_argument (N, &argc, argv);
     233    PRESERVE_PS1 = TRUE;
    228234  }
    229235
     
    672678  }
    673679
     680  PRESERVE_PS1 = FALSE;
     681  if ((N = get_argument (argc, argv, "-preserve-ps1"))) {
     682    remove_argument (N, &argc, argv);
     683    PRESERVE_PS1 = TRUE;
     684  }
     685
    674686  REPAIR_WARPS = FALSE;
    675687  if ((N = get_argument (argc, argv, "-repair-warps"))) {
  • trunk/Ohana/src/relphot/src/extra.c

    r38993 r39926  
    22
    33// for now (20140710) I need to identify gpc1 chips explicitly.  generalize in the future
     4// note that the 4000, 14000, 15000 sets are SIMTEST (*not* synthetic)
    45int whichGPC1filter (int photcode) {
    56
    6   if (((photcode > 10000) && (photcode < 10077)) || (photcode == 4100)) return PS1_g; // g-band
     7  if (((photcode > 10000) && (photcode < 10077)) || (photcode == 4100)) return PS1_g; // g-band 
    78  if (((photcode > 10100) && (photcode < 10177)) || (photcode == 4200)) return PS1_r; // r-band
    89  if (((photcode > 10200) && (photcode < 10277)) || (photcode == 4300)) return PS1_i; // i-band
     
    8384}
    8485
     86// for now (20160925) I need to identify HSC chips explicitly.  generalize in the future
     87int isHSCchip (int photcode) {
     88
     89  if ((photcode >= 20000) && (photcode <= 20111)) return TRUE; // g-band
     90  if ((photcode >= 21000) && (photcode <= 21111)) return TRUE; // r-band
     91  if ((photcode >= 22000) && (photcode <= 22111)) return TRUE; // i-band
     92  if ((photcode >= 23000) && (photcode <= 23111)) return TRUE; // z-band
     93  if ((photcode >= 24000) && (photcode <= 24111)) return TRUE; // y-band
     94
     95  return FALSE;
     96}
     97
     98// for now (20160925) I need to identify CFH chips explicitly.  generalize in the future
     99int isCFHchip (int photcode) {
     100
     101  if ((photcode >= 100) && (photcode <= 152)) return TRUE; // g-band
     102  if ((photcode >= 200) && (photcode <= 252)) return TRUE; // r-band
     103  if ((photcode >= 300) && (photcode <= 352)) return TRUE; // i-band
     104  if ((photcode >= 400) && (photcode <= 452)) return TRUE; // z-band
     105  if ((photcode >= 500) && (photcode <= 552)) return TRUE; // y-band
     106
     107  return FALSE;
     108}
     109
  • trunk/Ohana/src/relphot/src/reload_catalogs.c

    r39511 r39926  
    239239    if (RESET)             { strextend (&command, "-reset"); }
    240240    if (RESET_ZEROPTS)     { strextend (&command, "-reset-zpts"); }
     241    if (PRESERVE_PS1)      { strextend (&command, "-preserve-ps1"); }
    241242    if (UPDATE)            { strextend (&command, "-update"); }
    242243    if (IS_DIFF_DB)        { strextend (&command, "-is-diff-db"); }
  • trunk/Ohana/src/relphot/src/relphot_objects.c

    r39643 r39926  
    243243    if (RESET_ZEROPTS)     { strextend (&command, "-reset-zpts"); }
    244244    if (REPAIR_WARPS)      { strextend (&command, "-repair-warps"); }
     245    if (PRESERVE_PS1)      { strextend (&command, "-preserve-ps1"); }
    245246    if (IS_DIFF_DB)        { strextend (&command, "-is-diff-db"); }
    246247    if (UPDATE)            { strextend (&command, "-update"); }
  • trunk/Ohana/src/relphot/src/setMrelCatalog.c

    r39636 r39926  
    142142  int Galaxy2MASS = FALSE;
    143143  int haveTYCHO = FALSE;
     144  int haveHSC = FALSE;
     145  int haveCFH = FALSE;
    144146
    145147  float stargalmax = 0.0;
     
    163165   
    164166    if (isTYCHO(measureT[k].photcode)) { haveTYCHO = TRUE; }
     167    if (isHSCchip(measureT[k].photcode)) { haveHSC = TRUE; }
     168    if (isCFHchip(measureT[k].photcode)) { haveCFH = TRUE; }
    165169
    166170    if (is2MASS(measureT[k].photcode)) {
     
    317321  // now calculate the mean stats for the Nsec bands.
    318322  for (Nsec = 0; Nsec < Nsecfilt; Nsec++) {
    319     dvo_secfilt_init (&secfilt[Nsec], SECFILT_RESET_CHIP); // this does not reset astrometry or STACK bits
     323
     324    // if we detected this object in PS1, or do not request -preserve-ps1, keep the mean photometry values
     325    if (!PRESERVE_PS1 || !(secfilt[Nsec].flags & ID_SECF_HAS_PS1)) {
     326      dvo_secfilt_init (&secfilt[Nsec], SECFILT_RESET_CHIP); // this does not reset astrometry or STACK bits
     327    }
     328
     329    if (haveTYCHO) {
     330      secfilt[Nsec].flags |= ID_SECF_HAS_TYCHO;
     331    }
     332    if (haveHSC) {
     333      secfilt[Nsec].flags |= ID_SECF_HAS_HSC;
     334    }
     335    if (haveCFH) {
     336      secfilt[Nsec].flags |= ID_SECF_HAS_CFH;
     337    }
     338
     339    if (PRESERVE_PS1 && (secfilt[Nsec].flags & ID_SECF_HAS_PS1)) continue;
     340    // if -preserve-ps1 is set and this object has PS1 data, skip the rest of the steps:
    320341
    321342    // XXX hardwired grizy = (01234) JHK = (567) w = (8)
     
    324345    } else {
    325346      secfilt[Nsec].Ncode = results->Nmeas[Nsec]; // 2MASS data if it exists
    326     }
    327 
    328     if (haveTYCHO) {
    329       secfilt[Nsec].flags |= ID_SECF_HAS_TYCHO;
    330347    }
    331348
  • trunk/Ohana/src/uniphot/include/setgalmodel.h

    r38986 r39926  
    1010char        *HOSTDIR;
    1111int          VERBOSE;
    12 int          TESTING;
    1312int          UPDATE;
    1413int          PARALLEL;
     
    1817char        *SINGLE_CPT;
    1918
     19float        TEST_SCALE;
     20char        *GALAXY_MODEL;
    2021SkyRegion    UserPatch;
    2122
  • trunk/Ohana/src/uniphot/include/setphot.h

    r39356 r39926  
    6767int          VERBOSE;
    6868int          RESET;
     69int          PHOTCODE_MIN;
     70int          PHOTCODE_MAX;
    6971int          UBERCAL; // load the supplied ubercal zero point fits table (with flat-field corrections)
    7072int          NO_METADATA; // the supplied ubercal data has no descriptive metadata
  • trunk/Ohana/src/uniphot/src/initialize_setgalmodel.c

    r39225 r39926  
    4545
    4646  // XXX add to config?
    47   if (!InitGalaxyModel ("FEAST-HIPPARCOS")) {
    48     fprintf (stderr, "failed to init galaxy model\n");
     47  if (!InitGalaxyModel (GALAXY_MODEL)) {
     48    fprintf (stderr, "failed to init galaxy model %s\n", GALAXY_MODEL);
    4949    exit (2);
    5050  }
     
    9292  }
    9393
    94   TESTING = FALSE;
     94  GALAXY_MODEL = NULL;
     95  if ((N = get_argument (argc, argv, "-galaxy-model"))) {
     96    remove_argument (N, &argc, argv);
     97    GALAXY_MODEL = strcreate(argv[N]);
     98    remove_argument (N, &argc, argv);
     99  }
     100  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("FEAST-HIPPARCOS");
     101
     102  TEST_SCALE = 1.0;
    95103  if ((N = get_argument (argc, argv, "-testing"))) {
    96     TESTING = TRUE;
     104    remove_argument (N, &argc, argv);
     105    TEST_SCALE = atof(argv[N]);
    97106    remove_argument (N, &argc, argv);
    98107  }
     
    171180  }
    172181
    173   // XXX add to config?
    174   if (!InitGalaxyModel ("ROESER")) {
     182  // from args
     183  if (!InitGalaxyModel (GALAXY_MODEL)) {
    175184    fprintf (stderr, "failed to init galaxy model\n");
    176185    exit (2);
     
    212221  }
    213222
    214   TESTING = FALSE;
     223  GALAXY_MODEL = NULL;
     224  if ((N = get_argument (argc, argv, "-galaxy-model"))) {
     225    remove_argument (N, &argc, argv);
     226    GALAXY_MODEL = strcreate(argv[N]);
     227    remove_argument (N, &argc, argv);
     228  }
     229  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("FEAST-HIPPARCOS");
     230
     231  TEST_SCALE = 1.0;
    215232  if ((N = get_argument (argc, argv, "-testing"))) {
    216     TESTING = TRUE;
     233    remove_argument (N, &argc, argv);
     234    TEST_SCALE = atof(argv[N]);
    217235    remove_argument (N, &argc, argv);
    218236  }
  • trunk/Ohana/src/uniphot/src/initialize_setphot.c

    r39356 r39926  
    109109  if ((N = get_argument (argc, argv, "-reset"))) {
    110110    RESET = TRUE;
     111    remove_argument (N, &argc, argv);
     112  }
     113
     114  PHOTCODE_MIN = 0;
     115  PHOTCODE_MAX = 0;
     116  if ((N = get_argument (argc, argv, "-photcode-range"))) {
     117    remove_argument (N, &argc, argv);
     118    PHOTCODE_MIN = atoi (argv[N]);   
     119    remove_argument (N, &argc, argv);
     120    PHOTCODE_MAX = atoi (argv[N]);   
    111121    remove_argument (N, &argc, argv);
    112122  }
  • trunk/Ohana/src/uniphot/src/initialize_setphot_client.c

    r39356 r39926  
    9696  }
    9797
     98  PHOTCODE_MIN = 0;
     99  PHOTCODE_MAX = 0;
     100  if ((N = get_argument (argc, argv, "-photcode-range"))) {
     101    remove_argument (N, &argc, argv);
     102    PHOTCODE_MIN = atoi (argv[N]);   
     103    remove_argument (N, &argc, argv);
     104    PHOTCODE_MAX = atoi (argv[N]);   
     105    remove_argument (N, &argc, argv);
     106  }
     107
    98108  // region of interest
    99109  UserPatch.Rmin = 0;
  • trunk/Ohana/src/uniphot/src/update_catalog_setgalmodel.c

    r39586 r39926  
    3333
    3434    // fake or real QSOs are marked with FeH = +/- 100.0
    35     if (fabs(starpar->FeH) > 99.0) continue;
     35    if (fabs(starpar->FeH) > 99.0) {
     36      starpar->uRA  = 0.0;
     37      starpar->uDEC = 0.0;
     38      average[i].uRgal = 0.0;
     39      average[i].uDgal = 0.0;
     40      continue;
     41    }
    3642
    37     // NOTE: distance is in kiloparsec
     43    // NOTE: DistMag is standard (10pc reference).  SolarMotionModel wants distance in kiloparsec:
    3844    double distance = pow(10.0, 0.2*(starpar->DistMag + 5.0)) / 1000.0;
    3945
     
    5157
    5258    // XXX: amplify motion to make tests easier:
    53     if (TESTING) {
    54       uL *= 100.0;
    55       uB *= 100.0;
    56     }
     59    uL *= TEST_SCALE;
     60    uB *= TEST_SCALE;
    5761   
    5862    double uR, uD;
  • trunk/Ohana/src/uniphot/src/update_catalog_setphot.c

    r39457 r39926  
    11# include "setphot.h"
     2
     3// XXX I need to add a few things for HSC + MC + GPC1:
     4// * I can generate a zpt table for the MC exposures using the nominal zero points
     5// * for the HSC data, I need to add a function to define Mflat as a function of Xmos, Ymos
    26
    37void update_catalog_setphot (Catalog *catalog, Image *image, off_t *index, off_t Nimage, CamPhotomCorrection *camcorr) {
     
    1418    Measure *measure = &catalog[0].measure[i];
    1519
    16     // only do GPC1 data for now
    17     if (measure[0].photcode < 10000) continue;
    18     if (measure[0].photcode > 10600) continue;
     20    // XXX deprecated 2016.09.22 : only do GPC1 data for now
     21    // if (measure[0].photcode < 10000) continue;
     22    // if (measure[0].photcode > 10600) continue;
    1923     
     24    // only do DEP photcodes (skip REF, etc)
     25    PhotCode *code = GetPhotcodebyCode (measure[0].photcode);
     26    if (!code) continue; // invalid photcode
     27    if (code->type != PHOT_DEP) continue;
     28
     29    // allow a restriction on the modified zpts:
     30    if (PHOTCODE_MAX) {
     31      if (measure[0].photcode < PHOTCODE_MIN) continue;
     32      if (measure[0].photcode > PHOTCODE_MAX) continue;
     33    }
     34
    2035    off_t idx = measure[0].imageID;
    2136    if (idx <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode)
     
    3348      Mflat = CamPhotomCorrectionValue (camcorr, flat_id, measure[0].Xccd, measure[0].Yccd);
    3449    }
     50
     51# if (0)
     52    // the mosaic lookup is broken : fix it then redo this block
     53    if (radialZP) {
     54      mosaic = MatchMosaicMetadata (measure[0].imageID);
     55      if (mosaic == NULL) break;
     56      double Rm = measure[0].R;
     57      double Dm = measure[0].D;
     58      RD_to_XY (&XMOS_MEAS, &YMOS_MEAS, Rm, Dm, mosaic);
     59      Mflat = RadialZPtrend (XMOS_MEAS, XMOS_MEAS);
     60    }
     61# endif
    3562
    3663    measure[0].Mcal = Mcal;
  • trunk/Ohana/src/uniphot/src/update_dvo_setgalmodel.c

    r39225 r39926  
    9898
    9999    if (VERBOSE)          { strextend (&command, "-v"); }
    100     if (TESTING)          { strextend (&command, "-testing"); }
     100    if (TEST_SCALE != 1.0){ strextend (&command, "-testing %f", TEST_SCALE); }
    101101    if (UPDATE)           { strextend (&command, "-update"); }
    102102    if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); }
  • trunk/Ohana/src/uniphot/src/update_dvo_setphot.c

    r39356 r39926  
    179179    if (DCR_RESET)        { strextend (&command, "-DCR-reset"); }
    180180    if (CAM_RESET)        { strextend (&command, "-CAM-reset"); }
     181
     182    if (PHOTCODE_MAX)     { strextend (&command, "-photcode-range %d %d", PHOTCODE_MIN, PHOTCODE_MAX); }
    181183
    182184    fprintf (stderr, "command: %s\n", command);
  • trunk/ippScripts/scripts/camera_exp.pl

    r35800 r39926  
    404404
    405405    # Construct FPA continuity corrected background images
    406     if ($camera =~ /ISP/) {
     406    if (($camera =~ /ISP/)||($camera =~ /HSC/)) {
    407407        print "Skipping FPA continuity corrected background images for ISP\n";
    408408    } elsif ($do_bkg) {
  • trunk/ippScripts/scripts/nightly_science.pl

    • Property svn:mergeinfo deleted
  • trunk/ippTools/src/stacktool.c

    r38062 r39926  
    13281328    psFree(where);
    13291329
     1330    // This needs to be sorted by skycell_id, or the ppSkycell calls to mosaic things
     1331    // don't work properly.
     1332    psStringAppend(&query, " ORDER BY stackRun.skycell_id ");
     1333   
    13301334    // treat limit == 0 as "no limit"
    13311335    if (limit) {
  • trunk/ippconfig/dvo.photcodes

    r39705 r39926  
    152152  2022  TYCHO_B_2MASS        ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    153153  2023  TYCHO_V_2MASS        ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     154
     155  1030  GAIA_G_DR1           ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    154156
    155157  2025  BSC_U                ref   0.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     
    988990  566   MOSAIC2.I.06         dep  24.887  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000
    989991  567   MOSAIC2.I.07         dep  24.912  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 1.000  0.000   0x0000 0x3888  0x0000 0x0000
    990   20000 HSC.g.00             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    991   20001 HSC.g.01             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    992   20002 HSC.g.02             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    993   20003 HSC.g.03             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    994   20004 HSC.g.04             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    995   20005 HSC.g.05             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    996   20006 HSC.g.06             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    997   20007 HSC.g.07             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    998   20008 HSC.g.08             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    999   20009 HSC.g.09             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1000   20010 HSC.g.10             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1001   20011 HSC.g.11             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1002   20012 HSC.g.12             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1003   20013 HSC.g.13             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1004   20014 HSC.g.14             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1005   20015 HSC.g.15             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1006   20016 HSC.g.16             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1007   20017 HSC.g.17             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1008   20018 HSC.g.18             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1009   20019 HSC.g.19             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1010   20020 HSC.g.20             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1011   20021 HSC.g.21             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1012   20022 HSC.g.22             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1013   20023 HSC.g.23             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1014   20024 HSC.g.24             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1015   20025 HSC.g.25             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1016   20026 HSC.g.26             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1017   20027 HSC.g.27             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1018   20028 HSC.g.28             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1019   20029 HSC.g.29             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1020   20030 HSC.g.30             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1021   20031 HSC.g.31             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1022   20032 HSC.g.32             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1023   20033 HSC.g.33             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1024   20034 HSC.g.34             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1025   20035 HSC.g.35             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1026   20036 HSC.g.36             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1027   20037 HSC.g.37             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1028   20038 HSC.g.38             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1029   20039 HSC.g.39             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1030   20040 HSC.g.40             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1031   20041 HSC.g.41             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1032   20042 HSC.g.42             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1033   20043 HSC.g.43             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1034   20044 HSC.g.44             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1035   20045 HSC.g.45             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1036   20046 HSC.g.46             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1037   20047 HSC.g.47             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1038   20048 HSC.g.48             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1039   20049 HSC.g.49             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1040   20050 HSC.g.50             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1041   20051 HSC.g.51             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1042   20052 HSC.g.52             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1043   20053 HSC.g.53             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1044   20054 HSC.g.54             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1045   20055 HSC.g.55             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1046   20056 HSC.g.56             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1047   20057 HSC.g.57             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1048   20058 HSC.g.58             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1049   20059 HSC.g.59             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1050   20060 HSC.g.60             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1051   20061 HSC.g.61             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1052   20062 HSC.g.62             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1053   20063 HSC.g.63             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1054   20064 HSC.g.64             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1055   20065 HSC.g.65             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1056   20066 HSC.g.66             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1057   20067 HSC.g.67             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1058   20068 HSC.g.68             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1059   20069 HSC.g.69             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1060   20070 HSC.g.70             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1061   20071 HSC.g.71             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1062   20072 HSC.g.72             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1063   20073 HSC.g.73             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1064   20074 HSC.g.74             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1065   20075 HSC.g.75             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1066   20076 HSC.g.76             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1067   20077 HSC.g.77             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1068   20078 HSC.g.78             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1069   20079 HSC.g.79             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1070   20080 HSC.g.80             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1071   20081 HSC.g.81             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1072   20082 HSC.g.82             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1073   20083 HSC.g.83             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1074   20084 HSC.g.84             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1075   20085 HSC.g.85             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1076   20086 HSC.g.86             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1077   20087 HSC.g.87             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1078   20088 HSC.g.88             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1079   20089 HSC.g.89             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1080   20090 HSC.g.90             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1081   20091 HSC.g.91             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1082   20092 HSC.g.92             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1083   20093 HSC.g.93             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1084   20094 HSC.g.94             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1085   20095 HSC.g.95             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1086   20096 HSC.g.96             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1087   20097 HSC.g.97             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1088   20098 HSC.g.98             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1089   20099 HSC.g.99             dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1090   20100 HSC.g.100            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1091   20101 HSC.g.101            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1092   20102 HSC.g.102            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1093   20103 HSC.g.103            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1094   20104 HSC.g.104            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1095   20105 HSC.g.105            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1096   20106 HSC.g.106            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1097   20107 HSC.g.107            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1098   20108 HSC.g.108            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1099   20109 HSC.g.109            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1100   20110 HSC.g.110            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1101   20111 HSC.g.111            dep  25.000  0.000 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1102   21000 HSC.r.00             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1103   21001 HSC.r.01             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1104   21002 HSC.r.02             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1105   21003 HSC.r.03             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1106   21004 HSC.r.04             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1107   21005 HSC.r.05             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1108   21006 HSC.r.06             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1109   21007 HSC.r.07             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1110   21008 HSC.r.08             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1111   21009 HSC.r.09             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1112   21010 HSC.r.10             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1113   21011 HSC.r.11             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1114   21012 HSC.r.12             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1115   21013 HSC.r.13             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1116   21014 HSC.r.14             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1117   21015 HSC.r.15             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1118   21016 HSC.r.16             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1119   21017 HSC.r.17             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1120   21018 HSC.r.18             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1121   21019 HSC.r.19             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1122   21020 HSC.r.20             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1123   21021 HSC.r.21             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1124   21022 HSC.r.22             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1125   21023 HSC.r.23             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1126   21024 HSC.r.24             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1127   21025 HSC.r.25             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1128   21026 HSC.r.26             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1129   21027 HSC.r.27             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1130   21028 HSC.r.28             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1131   21029 HSC.r.29             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1132   21030 HSC.r.30             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1133   21031 HSC.r.31             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1134   21032 HSC.r.32             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1135   21033 HSC.r.33             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1136   21034 HSC.r.34             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1137   21035 HSC.r.35             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1138   21036 HSC.r.36             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1139   21037 HSC.r.37             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1140   21038 HSC.r.38             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1141   21039 HSC.r.39             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1142   21040 HSC.r.40             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1143   21041 HSC.r.41             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1144   21042 HSC.r.42             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1145   21043 HSC.r.43             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1146   21044 HSC.r.44             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1147   21045 HSC.r.45             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1148   21046 HSC.r.46             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1149   21047 HSC.r.47             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1150   21048 HSC.r.48             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1151   21049 HSC.r.49             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1152   21050 HSC.r.50             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1153   21051 HSC.r.51             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1154   21052 HSC.r.52             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1155   21053 HSC.r.53             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1156   21054 HSC.r.54             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1157   21055 HSC.r.55             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1158   21056 HSC.r.56             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1159   21057 HSC.r.57             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1160   21058 HSC.r.58             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1161   21059 HSC.r.59             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1162   21060 HSC.r.60             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1163   21061 HSC.r.61             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1164   21062 HSC.r.62             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1165   21063 HSC.r.63             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1166   21064 HSC.r.64             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1167   21065 HSC.r.65             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1168   21066 HSC.r.66             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1169   21067 HSC.r.67             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1170   21068 HSC.r.68             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1171   21069 HSC.r.69             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1172   21070 HSC.r.70             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1173   21071 HSC.r.71             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1174   21072 HSC.r.72             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1175   21073 HSC.r.73             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1176   21074 HSC.r.74             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1177   21075 HSC.r.75             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1178   21076 HSC.r.76             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1179   21077 HSC.r.77             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1180   21078 HSC.r.78             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1181   21079 HSC.r.79             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1182   21080 HSC.r.80             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1183   21081 HSC.r.81             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1184   21082 HSC.r.82             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1185   21083 HSC.r.83             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1186   21084 HSC.r.84             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1187   21085 HSC.r.85             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1188   21086 HSC.r.86             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1189   21087 HSC.r.87             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1190   21088 HSC.r.88             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1191   21089 HSC.r.89             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1192   21090 HSC.r.90             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1193   21091 HSC.r.91             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1194   21092 HSC.r.92             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1195   21093 HSC.r.93             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1196   21094 HSC.r.94             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1197   21095 HSC.r.95             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1198   21096 HSC.r.96             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1199   21097 HSC.r.97             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1200   21098 HSC.r.98             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1201   21099 HSC.r.99             dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1202   21100 HSC.r.100            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1203   21101 HSC.r.101            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1204   21102 HSC.r.102            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1205   21103 HSC.r.103            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1206   21104 HSC.r.104            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1207   21105 HSC.r.105            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1208   21106 HSC.r.106            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1209   21107 HSC.r.107            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1210   21108 HSC.r.108            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1211   21109 HSC.r.109            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1212   21110 HSC.r.110            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1213   21111 HSC.r.111            dep  25.000  0.000 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1214   22000 HSC.i.00             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1215   22001 HSC.i.01             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1216   22002 HSC.i.02             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1217   22003 HSC.i.03             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1218   22004 HSC.i.04             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1219   22005 HSC.i.05             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1220   22006 HSC.i.06             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1221   22007 HSC.i.07             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1222   22008 HSC.i.08             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1223   22009 HSC.i.09             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1224   22010 HSC.i.10             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1225   22011 HSC.i.11             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1226   22012 HSC.i.12             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1227   22013 HSC.i.13             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1228   22014 HSC.i.14             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1229   22015 HSC.i.15             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1230   22016 HSC.i.16             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1231   22017 HSC.i.17             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1232   22018 HSC.i.18             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1233   22019 HSC.i.19             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1234   22020 HSC.i.20             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1235   22021 HSC.i.21             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1236   22022 HSC.i.22             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1237   22023 HSC.i.23             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1238   22024 HSC.i.24             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1239   22025 HSC.i.25             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1240   22026 HSC.i.26             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1241   22027 HSC.i.27             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1242   22028 HSC.i.28             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1243   22029 HSC.i.29             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1244   22030 HSC.i.30             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1245   22031 HSC.i.31             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1246   22032 HSC.i.32             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1247   22033 HSC.i.33             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1248   22034 HSC.i.34             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1249   22035 HSC.i.35             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1250   22036 HSC.i.36             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1251   22037 HSC.i.37             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1252   22038 HSC.i.38             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1253   22039 HSC.i.39             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1254   22040 HSC.i.40             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1255   22041 HSC.i.41             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1256   22042 HSC.i.42             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1257   22043 HSC.i.43             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1258   22044 HSC.i.44             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1259   22045 HSC.i.45             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1260   22046 HSC.i.46             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1261   22047 HSC.i.47             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1262   22048 HSC.i.48             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1263   22049 HSC.i.49             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1264   22050 HSC.i.50             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1265   22051 HSC.i.51             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1266   22052 HSC.i.52             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1267   22053 HSC.i.53             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1268   22054 HSC.i.54             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1269   22055 HSC.i.55             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1270   22056 HSC.i.56             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1271   22057 HSC.i.57             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1272   22058 HSC.i.58             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1273   22059 HSC.i.59             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1274   22060 HSC.i.60             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1275   22061 HSC.i.61             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1276   22062 HSC.i.62             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1277   22063 HSC.i.63             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1278   22064 HSC.i.64             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1279   22065 HSC.i.65             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1280   22066 HSC.i.66             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1281   22067 HSC.i.67             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1282   22068 HSC.i.68             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1283   22069 HSC.i.69             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1284   22070 HSC.i.70             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1285   22071 HSC.i.71             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1286   22072 HSC.i.72             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1287   22073 HSC.i.73             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1288   22074 HSC.i.74             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1289   22075 HSC.i.75             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1290   22076 HSC.i.76             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1291   22077 HSC.i.77             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1292   22078 HSC.i.78             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1293   22079 HSC.i.79             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1294   22080 HSC.i.80             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1295   22081 HSC.i.81             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1296   22082 HSC.i.82             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1297   22083 HSC.i.83             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1298   22084 HSC.i.84             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1299   22085 HSC.i.85             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1300   22086 HSC.i.86             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1301   22087 HSC.i.87             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1302   22088 HSC.i.88             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1303   22089 HSC.i.89             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1304   22090 HSC.i.90             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1305   22091 HSC.i.91             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1306   22092 HSC.i.92             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1307   22093 HSC.i.93             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1308   22094 HSC.i.94             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1309   22095 HSC.i.95             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1310   22096 HSC.i.96             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1311   22097 HSC.i.97             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1312   22098 HSC.i.98             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1313   22099 HSC.i.99             dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1314   22100 HSC.i.100            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1315   22101 HSC.i.101            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1316   22102 HSC.i.102            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1317   22103 HSC.i.103            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1318   22104 HSC.i.104            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1319   22105 HSC.i.105            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1320   22106 HSC.i.106            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1321   22107 HSC.i.107            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1322   22108 HSC.i.108            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1323   22109 HSC.i.109            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1324   22110 HSC.i.110            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1325   22111 HSC.i.111            dep  25.000  0.000 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1326   23000 HSC.z.00             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1327   23001 HSC.z.01             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1328   23002 HSC.z.02             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1329   23003 HSC.z.03             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1330   23004 HSC.z.04             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1331   23005 HSC.z.05             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1332   23006 HSC.z.06             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1333   23007 HSC.z.07             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1334   23008 HSC.z.08             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1335   23009 HSC.z.09             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1336   23010 HSC.z.10             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1337   23011 HSC.z.11             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1338   23012 HSC.z.12             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1339   23013 HSC.z.13             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1340   23014 HSC.z.14             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1341   23015 HSC.z.15             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1342   23016 HSC.z.16             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1343   23017 HSC.z.17             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1344   23018 HSC.z.18             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1345   23019 HSC.z.19             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1346   23020 HSC.z.20             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1347   23021 HSC.z.21             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1348   23022 HSC.z.22             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1349   23023 HSC.z.23             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1350   23024 HSC.z.24             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1351   23025 HSC.z.25             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1352   23026 HSC.z.26             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1353   23027 HSC.z.27             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1354   23028 HSC.z.28             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1355   23029 HSC.z.29             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1356   23030 HSC.z.30             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1357   23031 HSC.z.31             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1358   23032 HSC.z.32             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1359   23033 HSC.z.33             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1360   23034 HSC.z.34             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1361   23035 HSC.z.35             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1362   23036 HSC.z.36             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1363   23037 HSC.z.37             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1364   23038 HSC.z.38             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1365   23039 HSC.z.39             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1366   23040 HSC.z.40             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1367   23041 HSC.z.41             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1368   23042 HSC.z.42             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1369   23043 HSC.z.43             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1370   23044 HSC.z.44             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1371   23045 HSC.z.45             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1372   23046 HSC.z.46             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1373   23047 HSC.z.47             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1374   23048 HSC.z.48             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1375   23049 HSC.z.49             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1376   23050 HSC.z.50             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1377   23051 HSC.z.51             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1378   23052 HSC.z.52             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1379   23053 HSC.z.53             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1380   23054 HSC.z.54             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1381   23055 HSC.z.55             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1382   23056 HSC.z.56             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1383   23057 HSC.z.57             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1384   23058 HSC.z.58             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1385   23059 HSC.z.59             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1386   23060 HSC.z.60             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1387   23061 HSC.z.61             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1388   23062 HSC.z.62             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1389   23063 HSC.z.63             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1390   23064 HSC.z.64             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1391   23065 HSC.z.65             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1392   23066 HSC.z.66             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1393   23067 HSC.z.67             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1394   23068 HSC.z.68             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1395   23069 HSC.z.69             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1396   23070 HSC.z.70             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1397   23071 HSC.z.71             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1398   23072 HSC.z.72             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1399   23073 HSC.z.73             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1400   23074 HSC.z.74             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1401   23075 HSC.z.75             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1402   23076 HSC.z.76             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1403   23077 HSC.z.77             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1404   23078 HSC.z.78             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1405   23079 HSC.z.79             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1406   23080 HSC.z.80             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1407   23081 HSC.z.81             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1408   23082 HSC.z.82             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1409   23083 HSC.z.83             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1410   23084 HSC.z.84             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1411   23085 HSC.z.85             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1412   23086 HSC.z.86             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1413   23087 HSC.z.87             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1414   23088 HSC.z.88             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1415   23089 HSC.z.89             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1416   23090 HSC.z.90             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1417   23091 HSC.z.91             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1418   23092 HSC.z.92             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1419   23093 HSC.z.93             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1420   23094 HSC.z.94             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1421   23095 HSC.z.95             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1422   23096 HSC.z.96             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1423   23097 HSC.z.97             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1424   23098 HSC.z.98             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1425   23099 HSC.z.99             dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1426   23100 HSC.z.100            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1427   23101 HSC.z.101            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1428   23102 HSC.z.102            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1429   23103 HSC.z.103            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1430   23104 HSC.z.104            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1431   23105 HSC.z.105            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1432   23106 HSC.z.106            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1433   23107 HSC.z.107            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1434   23108 HSC.z.108            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1435   23109 HSC.z.109            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1436   23110 HSC.z.110            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    1437   23111 HSC.z.111            dep  25.000  0.000 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     992
     993  20000 HSC.g.00             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     994  20001 HSC.g.01             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     995  20002 HSC.g.02             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     996  20003 HSC.g.03             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     997  20004 HSC.g.04             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     998  20005 HSC.g.05             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     999  20006 HSC.g.06             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1000  20007 HSC.g.07             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1001  20008 HSC.g.08             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1002  20009 HSC.g.09             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1003  20010 HSC.g.10             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1004  20011 HSC.g.11             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1005  20012 HSC.g.12             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1006  20013 HSC.g.13             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1007  20014 HSC.g.14             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1008  20015 HSC.g.15             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1009  20016 HSC.g.16             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1010  20017 HSC.g.17             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1011  20018 HSC.g.18             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1012  20019 HSC.g.19             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1013  20020 HSC.g.20             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1014  20021 HSC.g.21             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1015  20022 HSC.g.22             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1016  20023 HSC.g.23             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1017  20024 HSC.g.24             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1018  20025 HSC.g.25             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1019  20026 HSC.g.26             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1020  20027 HSC.g.27             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1021  20028 HSC.g.28             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1022  20029 HSC.g.29             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1023  20030 HSC.g.30             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1024  20031 HSC.g.31             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1025  20032 HSC.g.32             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1026  20033 HSC.g.33             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1027  20034 HSC.g.34             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1028  20035 HSC.g.35             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1029  20036 HSC.g.36             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1030  20037 HSC.g.37             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1031  20038 HSC.g.38             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1032  20039 HSC.g.39             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1033  20040 HSC.g.40             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1034  20041 HSC.g.41             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1035  20042 HSC.g.42             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1036  20043 HSC.g.43             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1037  20044 HSC.g.44             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1038  20045 HSC.g.45             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1039  20046 HSC.g.46             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1040  20047 HSC.g.47             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1041  20048 HSC.g.48             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1042  20049 HSC.g.49             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1043  20050 HSC.g.50             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1044  20051 HSC.g.51             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1045  20052 HSC.g.52             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1046  20053 HSC.g.53             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1047  20054 HSC.g.54             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1048  20055 HSC.g.55             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1049  20056 HSC.g.56             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1050  20057 HSC.g.57             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1051  20058 HSC.g.58             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1052  20059 HSC.g.59             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1053  20060 HSC.g.60             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1054  20061 HSC.g.61             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1055  20062 HSC.g.62             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1056  20063 HSC.g.63             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1057  20064 HSC.g.64             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1058  20065 HSC.g.65             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1059  20066 HSC.g.66             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1060  20067 HSC.g.67             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1061  20068 HSC.g.68             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1062  20069 HSC.g.69             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1063  20070 HSC.g.70             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1064  20071 HSC.g.71             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1065  20072 HSC.g.72             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1066  20073 HSC.g.73             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1067  20074 HSC.g.74             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1068  20075 HSC.g.75             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1069  20076 HSC.g.76             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1070  20077 HSC.g.77             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1071  20078 HSC.g.78             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1072  20079 HSC.g.79             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1073  20080 HSC.g.80             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1074  20081 HSC.g.81             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1075  20082 HSC.g.82             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1076  20083 HSC.g.83             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1077  20084 HSC.g.84             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1078  20085 HSC.g.85             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1079  20086 HSC.g.86             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1080  20087 HSC.g.87             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1081  20088 HSC.g.88             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1082  20089 HSC.g.89             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1083  20090 HSC.g.90             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1084  20091 HSC.g.91             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1085  20092 HSC.g.92             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1086  20093 HSC.g.93             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1087  20094 HSC.g.94             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1088  20095 HSC.g.95             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1089  20096 HSC.g.96             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1090  20097 HSC.g.97             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1091  20098 HSC.g.98             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1092  20099 HSC.g.99             dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1093  20100 HSC.g.100            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1094  20101 HSC.g.101            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1095  20102 HSC.g.102            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1096  20103 HSC.g.103            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1097  20104 HSC.g.104            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1098  20105 HSC.g.105            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1099  20106 HSC.g.106            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1100  20107 HSC.g.107            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1101  20108 HSC.g.108            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1102  20109 HSC.g.109            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1103  20110 HSC.g.110            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1104  20111 HSC.g.111            dep  26.750 -0.150 0.000     -     - 0.0000     0     1   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1105  21000 HSC.r.00             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1106  21001 HSC.r.01             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1107  21002 HSC.r.02             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1108  21003 HSC.r.03             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1109  21004 HSC.r.04             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1110  21005 HSC.r.05             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1111  21006 HSC.r.06             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1112  21007 HSC.r.07             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1113  21008 HSC.r.08             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1114  21009 HSC.r.09             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1115  21010 HSC.r.10             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1116  21011 HSC.r.11             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1117  21012 HSC.r.12             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1118  21013 HSC.r.13             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1119  21014 HSC.r.14             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1120  21015 HSC.r.15             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1121  21016 HSC.r.16             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1122  21017 HSC.r.17             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1123  21018 HSC.r.18             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1124  21019 HSC.r.19             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1125  21020 HSC.r.20             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1126  21021 HSC.r.21             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1127  21022 HSC.r.22             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1128  21023 HSC.r.23             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1129  21024 HSC.r.24             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1130  21025 HSC.r.25             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1131  21026 HSC.r.26             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1132  21027 HSC.r.27             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1133  21028 HSC.r.28             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1134  21029 HSC.r.29             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1135  21030 HSC.r.30             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1136  21031 HSC.r.31             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1137  21032 HSC.r.32             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1138  21033 HSC.r.33             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1139  21034 HSC.r.34             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1140  21035 HSC.r.35             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1141  21036 HSC.r.36             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1142  21037 HSC.r.37             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1143  21038 HSC.r.38             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1144  21039 HSC.r.39             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1145  21040 HSC.r.40             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1146  21041 HSC.r.41             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1147  21042 HSC.r.42             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1148  21043 HSC.r.43             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1149  21044 HSC.r.44             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1150  21045 HSC.r.45             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1151  21046 HSC.r.46             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1152  21047 HSC.r.47             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1153  21048 HSC.r.48             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1154  21049 HSC.r.49             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1155  21050 HSC.r.50             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1156  21051 HSC.r.51             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1157  21052 HSC.r.52             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1158  21053 HSC.r.53             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1159  21054 HSC.r.54             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1160  21055 HSC.r.55             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1161  21056 HSC.r.56             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1162  21057 HSC.r.57             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1163  21058 HSC.r.58             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1164  21059 HSC.r.59             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1165  21060 HSC.r.60             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1166  21061 HSC.r.61             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1167  21062 HSC.r.62             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1168  21063 HSC.r.63             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1169  21064 HSC.r.64             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1170  21065 HSC.r.65             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1171  21066 HSC.r.66             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1172  21067 HSC.r.67             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1173  21068 HSC.r.68             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1174  21069 HSC.r.69             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1175  21070 HSC.r.70             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1176  21071 HSC.r.71             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1177  21072 HSC.r.72             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1178  21073 HSC.r.73             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1179  21074 HSC.r.74             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1180  21075 HSC.r.75             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1181  21076 HSC.r.76             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1182  21077 HSC.r.77             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1183  21078 HSC.r.78             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1184  21079 HSC.r.79             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1185  21080 HSC.r.80             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1186  21081 HSC.r.81             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1187  21082 HSC.r.82             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1188  21083 HSC.r.83             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1189  21084 HSC.r.84             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1190  21085 HSC.r.85             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1191  21086 HSC.r.86             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1192  21087 HSC.r.87             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1193  21088 HSC.r.88             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1194  21089 HSC.r.89             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1195  21090 HSC.r.90             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1196  21091 HSC.r.91             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1197  21092 HSC.r.92             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1198  21093 HSC.r.93             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1199  21094 HSC.r.94             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1200  21095 HSC.r.95             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1201  21096 HSC.r.96             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1202  21097 HSC.r.97             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1203  21098 HSC.r.98             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1204  21099 HSC.r.99             dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1205  21100 HSC.r.100            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1206  21101 HSC.r.101            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1207  21102 HSC.r.102            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1208  21103 HSC.r.103            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1209  21104 HSC.r.104            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1210  21105 HSC.r.105            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1211  21106 HSC.r.106            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1212  21107 HSC.r.107            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1213  21108 HSC.r.108            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1214  21109 HSC.r.109            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1215  21110 HSC.r.110            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1216  21111 HSC.r.111            dep  27.100 -0.100 0.000     -     - 0.0000     0     2   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1217  22000 HSC.i.00             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1218  22001 HSC.i.01             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1219  22002 HSC.i.02             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1220  22003 HSC.i.03             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1221  22004 HSC.i.04             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1222  22005 HSC.i.05             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1223  22006 HSC.i.06             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1224  22007 HSC.i.07             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1225  22008 HSC.i.08             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1226  22009 HSC.i.09             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1227  22010 HSC.i.10             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1228  22011 HSC.i.11             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1229  22012 HSC.i.12             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1230  22013 HSC.i.13             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1231  22014 HSC.i.14             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1232  22015 HSC.i.15             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1233  22016 HSC.i.16             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1234  22017 HSC.i.17             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1235  22018 HSC.i.18             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1236  22019 HSC.i.19             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1237  22020 HSC.i.20             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1238  22021 HSC.i.21             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1239  22022 HSC.i.22             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1240  22023 HSC.i.23             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1241  22024 HSC.i.24             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1242  22025 HSC.i.25             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1243  22026 HSC.i.26             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1244  22027 HSC.i.27             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1245  22028 HSC.i.28             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1246  22029 HSC.i.29             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1247  22030 HSC.i.30             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1248  22031 HSC.i.31             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1249  22032 HSC.i.32             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1250  22033 HSC.i.33             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1251  22034 HSC.i.34             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1252  22035 HSC.i.35             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1253  22036 HSC.i.36             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1254  22037 HSC.i.37             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1255  22038 HSC.i.38             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1256  22039 HSC.i.39             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1257  22040 HSC.i.40             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1258  22041 HSC.i.41             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1259  22042 HSC.i.42             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1260  22043 HSC.i.43             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1261  22044 HSC.i.44             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1262  22045 HSC.i.45             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1263  22046 HSC.i.46             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1264  22047 HSC.i.47             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1265  22048 HSC.i.48             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1266  22049 HSC.i.49             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1267  22050 HSC.i.50             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1268  22051 HSC.i.51             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1269  22052 HSC.i.52             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1270  22053 HSC.i.53             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1271  22054 HSC.i.54             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1272  22055 HSC.i.55             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1273  22056 HSC.i.56             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1274  22057 HSC.i.57             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1275  22058 HSC.i.58             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1276  22059 HSC.i.59             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1277  22060 HSC.i.60             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1278  22061 HSC.i.61             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1279  22062 HSC.i.62             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1280  22063 HSC.i.63             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1281  22064 HSC.i.64             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1282  22065 HSC.i.65             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1283  22066 HSC.i.66             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1284  22067 HSC.i.67             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1285  22068 HSC.i.68             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1286  22069 HSC.i.69             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1287  22070 HSC.i.70             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1288  22071 HSC.i.71             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1289  22072 HSC.i.72             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1290  22073 HSC.i.73             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1291  22074 HSC.i.74             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1292  22075 HSC.i.75             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1293  22076 HSC.i.76             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1294  22077 HSC.i.77             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1295  22078 HSC.i.78             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1296  22079 HSC.i.79             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1297  22080 HSC.i.80             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1298  22081 HSC.i.81             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1299  22082 HSC.i.82             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1300  22083 HSC.i.83             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1301  22084 HSC.i.84             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1302  22085 HSC.i.85             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1303  22086 HSC.i.86             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1304  22087 HSC.i.87             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1305  22088 HSC.i.88             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1306  22089 HSC.i.89             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1307  22090 HSC.i.90             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1308  22091 HSC.i.91             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1309  22092 HSC.i.92             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1310  22093 HSC.i.93             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1311  22094 HSC.i.94             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1312  22095 HSC.i.95             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1313  22096 HSC.i.96             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1314  22097 HSC.i.97             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1315  22098 HSC.i.98             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1316  22099 HSC.i.99             dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1317  22100 HSC.i.100            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1318  22101 HSC.i.101            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1319  22102 HSC.i.102            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1320  22103 HSC.i.103            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1321  22104 HSC.i.104            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1322  22105 HSC.i.105            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1323  22106 HSC.i.106            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1324  22107 HSC.i.107            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1325  22108 HSC.i.108            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1326  22109 HSC.i.109            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1327  22110 HSC.i.110            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1328  22111 HSC.i.111            dep  27.000 -0.040 0.000     -     - 0.0000     0     3   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1329  23000 HSC.z.00             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1330  23001 HSC.z.01             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1331  23002 HSC.z.02             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1332  23003 HSC.z.03             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1333  23004 HSC.z.04             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1334  23005 HSC.z.05             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1335  23006 HSC.z.06             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1336  23007 HSC.z.07             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1337  23008 HSC.z.08             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1338  23009 HSC.z.09             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1339  23010 HSC.z.10             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1340  23011 HSC.z.11             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1341  23012 HSC.z.12             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1342  23013 HSC.z.13             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1343  23014 HSC.z.14             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1344  23015 HSC.z.15             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1345  23016 HSC.z.16             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1346  23017 HSC.z.17             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1347  23018 HSC.z.18             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1348  23019 HSC.z.19             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1349  23020 HSC.z.20             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1350  23021 HSC.z.21             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1351  23022 HSC.z.22             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1352  23023 HSC.z.23             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1353  23024 HSC.z.24             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1354  23025 HSC.z.25             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1355  23026 HSC.z.26             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1356  23027 HSC.z.27             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1357  23028 HSC.z.28             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1358  23029 HSC.z.29             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1359  23030 HSC.z.30             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1360  23031 HSC.z.31             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1361  23032 HSC.z.32             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1362  23033 HSC.z.33             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1363  23034 HSC.z.34             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1364  23035 HSC.z.35             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1365  23036 HSC.z.36             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1366  23037 HSC.z.37             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1367  23038 HSC.z.38             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1368  23039 HSC.z.39             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1369  23040 HSC.z.40             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1370  23041 HSC.z.41             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1371  23042 HSC.z.42             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1372  23043 HSC.z.43             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1373  23044 HSC.z.44             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1374  23045 HSC.z.45             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1375  23046 HSC.z.46             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1376  23047 HSC.z.47             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1377  23048 HSC.z.48             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1378  23049 HSC.z.49             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1379  23050 HSC.z.50             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1380  23051 HSC.z.51             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1381  23052 HSC.z.52             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1382  23053 HSC.z.53             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1383  23054 HSC.z.54             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1384  23055 HSC.z.55             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1385  23056 HSC.z.56             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1386  23057 HSC.z.57             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1387  23058 HSC.z.58             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1388  23059 HSC.z.59             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1389  23060 HSC.z.60             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1390  23061 HSC.z.61             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1391  23062 HSC.z.62             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1392  23063 HSC.z.63             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1393  23064 HSC.z.64             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1394  23065 HSC.z.65             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1395  23066 HSC.z.66             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1396  23067 HSC.z.67             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1397  23068 HSC.z.68             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1398  23069 HSC.z.69             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1399  23070 HSC.z.70             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1400  23071 HSC.z.71             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1401  23072 HSC.z.72             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1402  23073 HSC.z.73             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1403  23074 HSC.z.74             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1404  23075 HSC.z.75             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1405  23076 HSC.z.76             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1406  23077 HSC.z.77             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1407  23078 HSC.z.78             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1408  23079 HSC.z.79             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1409  23080 HSC.z.80             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1410  23081 HSC.z.81             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1411  23082 HSC.z.82             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1412  23083 HSC.z.83             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1413  23084 HSC.z.84             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1414  23085 HSC.z.85             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1415  23086 HSC.z.86             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1416  23087 HSC.z.87             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1417  23088 HSC.z.88             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1418  23089 HSC.z.89             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1419  23090 HSC.z.90             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1420  23091 HSC.z.91             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1421  23092 HSC.z.92             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1422  23093 HSC.z.93             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1423  23094 HSC.z.94             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1424  23095 HSC.z.95             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1425  23096 HSC.z.96             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1426  23097 HSC.z.97             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1427  23098 HSC.z.98             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1428  23099 HSC.z.99             dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1429  23100 HSC.z.100            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1430  23101 HSC.z.101            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1431  23102 HSC.z.102            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1432  23103 HSC.z.103            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1433  23104 HSC.z.104            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1434  23105 HSC.z.105            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1435  23106 HSC.z.106            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1436  23107 HSC.z.107            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1437  23108 HSC.z.108            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1438  23109 HSC.z.109            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1439  23110 HSC.z.110            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1440  23111 HSC.z.111            dep  26.200 -0.030 0.000     -     - 0.0000     0     4   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    14381441  24000 HSC.y.00             dep  25.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    14391442  24001 HSC.y.01             dep  25.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     
    15481551  24110 HSC.y.110            dep  25.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
    15491552  24111 HSC.y.111            dep  25.000  0.000 0.000     -     - 0.0000     0     5   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1553  25000 HSC.NB921.00             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1554  25001 HSC.NB921.01             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1555  25002 HSC.NB921.02             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1556  25003 HSC.NB921.03             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1557  25004 HSC.NB921.04             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1558  25005 HSC.NB921.05             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1559  25006 HSC.NB921.06             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1560  25007 HSC.NB921.07             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1561  25008 HSC.NB921.08             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1562  25009 HSC.NB921.09             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1563  25010 HSC.NB921.10             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1564  25011 HSC.NB921.11             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1565  25012 HSC.NB921.12             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1566  25013 HSC.NB921.13             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1567  25014 HSC.NB921.14             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1568  25015 HSC.NB921.15             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1569  25016 HSC.NB921.16             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1570  25017 HSC.NB921.17             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1571  25018 HSC.NB921.18             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1572  25019 HSC.NB921.19             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1573  25020 HSC.NB921.20             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1574  25021 HSC.NB921.21             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1575  25022 HSC.NB921.22             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1576  25023 HSC.NB921.23             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1577  25024 HSC.NB921.24             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1578  25025 HSC.NB921.25             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1579  25026 HSC.NB921.26             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1580  25027 HSC.NB921.27             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1581  25028 HSC.NB921.28             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1582  25029 HSC.NB921.29             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1583  25030 HSC.NB921.30             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1584  25031 HSC.NB921.31             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1585  25032 HSC.NB921.32             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1586  25033 HSC.NB921.33             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1587  25034 HSC.NB921.34             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1588  25035 HSC.NB921.35             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1589  25036 HSC.NB921.36             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1590  25037 HSC.NB921.37             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1591  25038 HSC.NB921.38             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1592  25039 HSC.NB921.39             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1593  25040 HSC.NB921.40             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1594  25041 HSC.NB921.41             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1595  25042 HSC.NB921.42             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1596  25043 HSC.NB921.43             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1597  25044 HSC.NB921.44             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1598  25045 HSC.NB921.45             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1599  25046 HSC.NB921.46             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1600  25047 HSC.NB921.47             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1601  25048 HSC.NB921.48             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1602  25049 HSC.NB921.49             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1603  25050 HSC.NB921.50             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1604  25051 HSC.NB921.51             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1605  25052 HSC.NB921.52             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1606  25053 HSC.NB921.53             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1607  25054 HSC.NB921.54             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1608  25055 HSC.NB921.55             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1609  25056 HSC.NB921.56             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1610  25057 HSC.NB921.57             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1611  25058 HSC.NB921.58             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1612  25059 HSC.NB921.59             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1613  25060 HSC.NB921.60             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1614  25061 HSC.NB921.61             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1615  25062 HSC.NB921.62             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1616  25063 HSC.NB921.63             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1617  25064 HSC.NB921.64             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1618  25065 HSC.NB921.65             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1619  25066 HSC.NB921.66             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1620  25067 HSC.NB921.67             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1621  25068 HSC.NB921.68             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1622  25069 HSC.NB921.69             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1623  25070 HSC.NB921.70             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1624  25071 HSC.NB921.71             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1625  25072 HSC.NB921.72             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1626  25073 HSC.NB921.73             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1627  25074 HSC.NB921.74             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1628  25075 HSC.NB921.75             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1629  25076 HSC.NB921.76             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1630  25077 HSC.NB921.77             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1631  25078 HSC.NB921.78             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1632  25079 HSC.NB921.79             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1633  25080 HSC.NB921.80             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1634  25081 HSC.NB921.81             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1635  25082 HSC.NB921.82             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1636  25083 HSC.NB921.83             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1637  25084 HSC.NB921.84             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1638  25085 HSC.NB921.85             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1639  25086 HSC.NB921.86             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1640  25087 HSC.NB921.87             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1641  25088 HSC.NB921.88             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1642  25089 HSC.NB921.89             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1643  25090 HSC.NB921.90             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1644  25091 HSC.NB921.91             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1645  25092 HSC.NB921.92             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1646  25093 HSC.NB921.93             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1647  25094 HSC.NB921.94             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1648  25095 HSC.NB921.95             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1649  25096 HSC.NB921.96             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1650  25097 HSC.NB921.97             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1651  25098 HSC.NB921.98             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1652  25099 HSC.NB921.99             dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1653  25100 HSC.NB921.100            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1654  25101 HSC.NB921.101            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1655  25102 HSC.NB921.102            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1656  25103 HSC.NB921.103            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1657  25104 HSC.NB921.104            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1658  25105 HSC.NB921.105            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1659  25106 HSC.NB921.106            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1660  25107 HSC.NB921.107            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1661  25108 HSC.NB921.108            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1662  25109 HSC.NB921.109            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1663  25110 HSC.NB921.110            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1664  25111 HSC.NB921.111            dep  25.000  0.000 0.000     -     - 0.0000     0     -   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000
     1665
  • trunk/ippconfig/hsc

    • Property svn:ignore set to
      Makefile
      Makefile.in
  • trunk/ippconfig/hsc/Makefile.am

    r39705 r39926  
    77        format_raw.config \
    88        format_mef.config \
     9        format_cmf.config \
    910        ppImage.config \
    1011        ppMerge.config \
    1112        psastro.config \
    12         ppStats.config
     13        ppStats.config \
     14        ppStack.config
    1315
    1416install_DATA = $(install_files)
  • trunk/ippconfig/hsc/camera.config

    r39705 r39926  
    55        MEF     STR     hsc/format_mef.config  # for output cmfs from, e.g., camera
    66        RAW     STR     hsc/format_raw.config
     7        CMF     STR     hsc/format_cmf.config  # chip output cmfs
    78#       SPLIT   STR     hsc/format_split.config
    89END
     
    139140   z        STR   HSC-z
    140141   y        STR   HSC-Y
     142   NB921    STR   NB0921
    141143END
    142144
     
    176178#       PPSTACK         STR     hsc/ppStack.config          # ppStack recipe
    177179        PPSTATS         STR     hsc/ppStats.config
     180        PPSTACK         STR     hsc/ppStack.config
    178181END
    179182
  • trunk/ippconfig/hsc/format_mef.config

    r39705 r39926  
    193193        FPA.FILTER      STR     FILTER01
    194194        FPA.FILTERID    STR     FILTER01
    195         FPA.POSANGLE    STR     INR-STR
    196 #       FPA.POSANGLE    STR     INST-PA (not sure which is right)
     195#       FPA.POSANGLE    STR     INR-STR -- this is equivalent to the GPC1 ROT, not POS
     196        FPA.POSANGLE    STR     INST-PA
    197197        FPA.RA          STR     RA
    198198        FPA.DEC         STR     DEC
     
    219219#       FPA.ENV.DIR     STR     OUT-TMP
    220220        FPA.TELTEMP.TRUSS  STR  DOM-TMP # Mid truss temperatures (C
     221        FPA.ZP          STR     ZPT_OBS
     222
    221223
    222224        CHIP.TEMP       STR     DET-TMP
  • trunk/ippconfig/hsc/format_raw.config

    r39705 r39926  
    55        TELESCOP        STR     Subaru
    66        INSTRUME        STR     Hyper Suprime-Cam
    7 #       NAXIS           S32     2 # with 2 this is an image (with 0, this is an output smf)
     7        NAXIS           S32     2 # with 2 this is an image (with 0, this is an output smf)
    88END
    99
     
    192192        FPA.FILTER      STR     FILTER01
    193193        FPA.FILTERID    STR     FILTER01
    194         FPA.POSANGLE    STR     INR-STR
    195 #       FPA.POSANGLE    STR     INST-PA (not sure which is right)
     194#       FPA.POSANGLE    STR     INR-STR
     195        FPA.POSANGLE    STR     INST-PA
    196196        FPA.RA          STR     RA
    197197        FPA.DEC         STR     DEC
  • trunk/ippconfig/hsc/ppImage.config

    r39504 r39926  
    1414    FILTER  STR FPA.FILTERID
    1515  END
     16
     17  FRINGE METADATA
     18    FILTER  STR FPA.FILTERID
     19  END
    1620END   
     21
     22FRINGE.FILTERS MULTI
     23FRINGE.FILTERS STR HSC-Y
    1724
    1825# Standard chip processing
     
    3138  FLAT               BOOL    TRUE            # Flat-field normalisation
    3239  MASK               BOOL    TRUE            # Mask bad pixels
    33   FRINGE             BOOL    FALSE           # Fringe subtraction
     40  FRINGE             BOOL    TRUE            # Fringe subtraction
    3441  BIN1.FITS          BOOL    TRUE            # Save 1st binned chip image?
    3542  BIN2.FITS          BOOL    TRUE            # Save 2nd binned chip image?
     
    9198END
    9299
     100# This is the processing recipe for fringes
     101PPIMAGE_OBDSF       METADATA
     102  BASE.FITS          BOOL    TRUE            # Save base detrended image?
     103  BASE.MASK.FITS     BOOL    TRUE            # Save base detrended image?
     104  BASE.VARIANCE.FITS BOOL    TRUE            # Save base detrended image?
     105  CHIP.FITS          BOOL    FALSE           # Save chip-mosaic-ed image?
     106  CHIP.MASK.FITS     BOOL    FALSE           # Save chip-mosaic-ed image?
     107  CHIP.VARIANCE.FITS BOOL    FALSE           # Save chip-mosaic-ed image?
     108  OVERSCAN           BOOL    TRUE            # Overscan subtraction
     109  NONLIN             BOOL    FALSE           # Non-linearity correction; not implemented
     110  BIAS               BOOL    TRUE            # Bias subtraction
     111  DARK               BOOL    FALSE           # Dark subtraction
     112  SHUTTER            BOOL    FALSE           # Shutter correction
     113  FLAT               BOOL    TRUE            # Flat-field normalisation
     114  MASK               BOOL    TRUE            # Mask bad pixels
     115  MASK.BUILD         BOOL    FALSE           # Build internal mask?
     116  FRINGE             BOOL    FALSE           # Fringe subtraction
     117  PHOTOM             BOOL    FALSE           # Source identification and photometry
     118  ASTROM.CHIP        BOOL    FALSE           # Astrometry per chip?
     119  ASTROM.MOSAIC      BOOL    FALSE           # Astrometry for mosaic?
     120  BIN1.FITS          BOOL    TRUE            # Save 1st binned chip image?
     121  BIN2.FITS          BOOL    TRUE            # Save 2nd binned chip image?
     122END
     123
    93124# Overscan, bias, dark, shutter, flat-field -- use FLAT_PREMASK
    94125PPIMAGE_FLATMASK_PROCESS      METADATA
  • trunk/ippconfig/hsc/ppMerge.config

    r39504 r39926  
     1
     2FRINGE.NUM              S32     6250     # number of fringe regions per cell
     3FRINGE.SIZE             S32     5        # Half-size of fringe regions
     4FRINGE.XSMOOTH          S32     3        # Number of smoothing regions per cell in x
     5FRINGE.YSMOOTH          S32     3        # Number of smoothing regions per cell in y
     6FRINGE.SMOOTH           BOOL    T        # Smooth the output image?
     7FRINGE.SMOOTH.SIGMA     F32     2.0      # Sigma of smoothing Gaussian
     8
    19
    210# Bias combination --- don't want min/max rejection
     
    1220        STDEV           STR     ROBUST_STDEV    # Statistic to use to measure the stdev
    1321END
     22
     23
  • trunk/ippconfig/hsc/psastro.config

    r39504 r39926  
    66DVO.GETSTAR.OUTFORMAT         STR      PS1_DEV_0
    77DVO.GETSTAR.PHOTCODE          STR      i
    8 DVO.GETSTAR.MAX.RHO           F32      10000.0
     8DVO.GETSTAR.MAX.RHO           F32      30000.0
    99DVO.GETSTAR.MIN.MAG           F32      12.0
    1010DVO.GETSTAR.MIN.MAG.INST      F32     -15.0
     
    1313PHOTCODE.DATA METADATA
    1414  FILTER   STR g
    15   ZEROPT   F32 28.0
     15  ZEROPT   F32 26.75
    1616  PHOTCODE STR g
    1717  GHOST_MAX_MAG                   F32 -16.5
     
    1919PHOTCODE.DATA METADATA
    2020  FILTER   STR r
    21   ZEROPT   F32 28.0
     21  ZEROPT   F32 27.1
    2222  PHOTCODE STR r
    2323  GHOST_MAX_MAG                   F32 -20.0
     
    2525PHOTCODE.DATA METADATA
    2626  FILTER   STR i
    27   ZEROPT   F32 26.9
     27  ZEROPT   F32 27.0
    2828  PHOTCODE STR i
    2929  GHOST_MAX_MAG                   F32 -25.0
     
    3131PHOTCODE.DATA METADATA
    3232  FILTER   STR z
    33   ZEROPT   F32 28.0
     33  ZEROPT   F32 26.2
     34  PHOTCODE STR z
     35  GHOST_MAX_MAG                   F32 -25.0
     36END
     37PHOTCODE.DATA METADATA
     38  FILTER   STR y
     39  ZEROPT   F32 25.1
     40  PHOTCODE STR y
     41  GHOST_MAX_MAG                   F32 -25.0
     42END
     43PHOTCODE.DATA METADATA
     44  FILTER   STR NB921
     45  ZEROPT   F32 25.4
    3446  PHOTCODE STR z
    3547  GHOST_MAX_MAG                   F32 -25.0
    3648END
    3749
     50
     51PSASTRO.USE.MODEL            BOOL TRUE
     52
     53# extra field for ref stars:
     54PSASTRO.PHOTOM.WINDOW.SIGMA  F32 0.0
     55
     56PSASTRO.GRID.MIN.ANGLE F32 -2.0 # start angle (degrees)
     57PSASTRO.GRID.MAX.ANGLE F32 +2.0
     58PSASTRO.GRID.DEL.ANGLE F32  1.0
     59
     60PSASTRO.GRID.NREF.MAX  S32   1000 # max stars accepted for fitting
     61PSASTRO.GRID.NRAW.MAX  S32   1000 # max stars accepted for fitting
     62
     63PSASTRO.GRID.MIN.INST.MAG.RAW       F32      -14
     64PSASTRO.GRID.MAX.INST.MAG.RAW       F32       -9
     65
    3866# pmAstromMatchFit
    39 PSASTRO.CHIP.ORDER     S32      3  # fit order
     67PSASTRO.CHIP.ORDER     S32      1  # fit order
    4068PSASTRO.CHIP.NITER     S32      3  # fit clipping iterations
    4169PSASTRO.CHIP.NSIGMA    F32      3  # fit clipping sigmas
    4270
    4371# single-chip radius match in pixels
    44 PSASTRO.MATCH.RADIUS.N0 F32    90
    45 PSASTRO.MATCH.RADIUS.N1 F32    60
    46 PSASTRO.MATCH.RADIUS.N2 F32    30
    47 PSASTRO.MATCH.RADIUS.N3 F32    20
    48 PSASTRO.MATCH.RADIUS.N4 F32    20
    49 PSASTRO.MATCH.RADIUS.N5 F32    10
    50 PSASTRO.MATCH.RADIUS.N6 F32    10
    51 PSASTRO.MATCH.RADIUS.N7 F32    5
    52 PSASTRO.MATCH.FIT.NITER S32    8
     72PSASTRO.MATCH.RADIUS.N0 F32    30
     73PSASTRO.MATCH.RADIUS.N1 F32    20
     74PSASTRO.MATCH.RADIUS.N2 F32    20
     75PSASTRO.MATCH.RADIUS.N3 F32    10
     76PSASTRO.MATCH.RADIUS.N4 F32    10
     77PSASTRO.MATCH.RADIUS.N5 F32     8 # was 5
     78PSASTRO.MATCH.RADIUS.N6 F32     2
     79PSASTRO.MATCH.RADIUS.N7 F32     0
     80PSASTRO.MATCH.FIT.NITER S32     6 # was 7
    5381
     82# Mosaic Astrometry options
     83PSASTRO.MOSAIC.MODE         BOOL   TRUE
     84
     85# for iterations >= N, require a single match per reference
     86PSASTRO.MOSAIC.CHIP.NITER     S32      5  # fit clipping iterations (NOTE: last iteration is NITER, not NITER - 1)
     87PSASTRO.MOSAIC.CHIP.NSIGMA    F32      3  # fit clipping sigmas
     88PSASTRO.MOSAIC.UNIQ.ITER      S32      3  # for iterations >= N, require a single match per reference
     89
     90PSASTRO.MOSAIC.MAX.ERROR.N0 F32    0.00 # max allow error for valid solution (arcsec)
     91PSASTRO.MOSAIC.MAX.ERROR.N1 F32    0.00 # max allow error for valid solution (arcsec)
     92PSASTRO.MOSAIC.MAX.ERROR.N2 F32    0.00 # max allow error for valid solution (arcsec)
     93PSASTRO.MOSAIC.MAX.ERROR.N3 F32    0.00 # max allow error for valid solution (arcsec)
     94PSASTRO.MOSAIC.MAX.ERROR.N4 F32    0.00 # max allow error for valid solution (arcsec)
     95PSASTRO.MOSAIC.MAX.ERROR.N5 F32    0.30 # max allow error for valid solution (arcsec)
     96
     97# mosaic radius match in pixels (do these make sense?)
     98PSASTRO.MOSAIC.RADIUS.N0    F32    15
     99PSASTRO.MOSAIC.RADIUS.N1    F32    10
     100PSASTRO.MOSAIC.RADIUS.N2    F32    10
     101PSASTRO.MOSAIC.RADIUS.N3    F32    5
     102PSASTRO.MOSAIC.RADIUS.N4    F32    5
     103PSASTRO.MOSAIC.RADIUS.N5    F32    3
     104
     105PSASTRO.MOSAIC.CHIP.ORDER     S32      1  # limit chip-fit order to 1
     106PSASTRO.MOSAIC.CHIP.ORDER.N0  S32      0 # fit order (-1 means use default)
     107PSASTRO.MOSAIC.CHIP.ORDER.N1  S32      0 # fit order (-1 means use default)
     108PSASTRO.MOSAIC.CHIP.ORDER.N2  S32      1 # fit order (-1 means use default)
     109PSASTRO.MOSAIC.CHIP.ORDER.N3  S32      1 # fit order (-1 means use default)
     110PSASTRO.MOSAIC.CHIP.ORDER.N4  S32      3 # fit order (-1 means use default)
     111PSASTRO.MOSAIC.CHIP.ORDER.N5  S32      3 # fit order (-1 means use default)
     112
     113PSASTRO.MODEL.REF.CHIP        STR      x050
     114PSASTRO.MODEL.REF.CHIP.ANGLE  F32      90.0
     115PSASTRO.MODEL.ROT.PARITY      S32      -1
  • trunk/ippconfig/megacam/dvo.config

    r20858 r39926  
    2020CCDNUM-KEYWORD          EXTNAME
    2121ST-KEYWORD              NONE
    22 OBSERVATORY-LATITUDE    NONE
    23 OBSERVATORY-LONGITUDE   NONE
     22OBSERVATORY-LATITUDE    19.825237
     23OBSERVATORY-LONGITUDE   10.3645844667
    2424SUBPIX_DATAFILE         NONE
    2525
  • trunk/ippconfig/megacam/psastro.config

    r35723 r39926  
    137137END
    138138
    139 PSASTRO.CATDIR              STR      SYNTH.GRIZY
    140 DVO.GETSTAR.MAX.RHO         F32      3000.0
     139PSASTRO.CATDIR              STR      PS1.REF.20140713
     140# PSASTRO.CATDIR              STR      SYNTH.GRIZY
     141DVO.GETSTAR.MAX.RHO         F32      30000.0
     142DVO.GETSTAR.OUTFORMAT       STR      PS1_DEV_0
    141143DVO.GETSTAR.MIN.MAG         F32      12.0
    142144DVO.GETSTAR.MIN.MAG.INST    F32     -15.0
  • trunk/ippconfig/recipes/nightly_science.config

    • Property svn:mergeinfo deleted
  • trunk/ippconfig/recipes/psastro.config

    r39503 r39926  
    2222# extra field for ref stars:
    2323PSASTRO.FIELD.PADDING  F32 0.25
     24
     25# extra field for ref stars:
     26PSASTRO.PHOTOM.WINDOW.SIGMA  F32 0.0
    2427
    2528# pmAstromGridMatch:
     
    233236
    234237PSASTRO.MODEL.REF.CHIP        STR      NONE
     238PSASTRO.MODEL.REF.CHIP.ANGLE  F32      0.0
     239PSASTRO.MODEL.ROT.PARITY      S32      +1
    235240PSASTRO.MODEL.FIT.BORESITE    BOOL     FALSE
    236241PSASTRO.MODEL.SET.BORESITE    BOOL     FALSE
  • trunk/ippconfig/recipes/psphot.config

    r39818 r39926  
    6464FOOTPRINT_GROW_RADIUS               S32   3               # How much to grow bright footprints
    6565FOOTPRINT_GROW_RADIUS_2             S32   5               # How much to grow faint footprints
    66 FOOTPRINT_CULL_NSIGMA_DELTA         F32   4               # Cull peaks that aren't nsigma above coll to neighbour
    67 FOOTPRINT_CULL_NSIGMA_MIN           F32   1               # Minimum height of colls in units of skyStdev
     66FOOTPRINT_CULL_NSIGMA_DELTA         F32   4               # Cull peaks that aren't nsigma above col to neighbour
     67FOOTPRINT_CULL_NSIGMA_MIN           F32   1               # Minimum height of cols in units of skyStdev
    6868FOOTPRINT_CULL_NSIGMA_PAD           F32   0.01            # Fractional Padding for stdev
    6969FOOTPRINT_USE_UNSUBTRACTED          BOOL  TRUE            # find footprints without sources subtracted
  • trunk/ppMerge/src/ppMergeLoop.c

    r35687 r39926  
    398398
    399399            psFree(fileGroups);
    400             psFree(zeros);
     400            //            psFree(zeros);
    401401
    402402            // XXX eventually need to keep both the shutter and the pattern, as we do with dark
  • trunk/psLib/src/astro/psCoord.c

    r19504 r39926  
    234234    const psPlane* coords)
    235235{
     236  if (!transform) {
     237    fprintf (stderr, "problem\n");
     238  }
    236239    PS_ASSERT_PTR_NON_NULL(transform, NULL);
    237240    PS_ASSERT_PTR_NON_NULL(transform->x, NULL);
     
    305308void projectionFree(psProjection *p)
    306309{
    307     // There are no dynamically allocated items
     310  if (!p) return;
     311  if (!p->radial) return;
     312  psFree (p->radial);
    308313}
    309314
     
    321326    p->Ys = Ys;
    322327    p->type = type;
     328    p->radial = NULL;
    323329
    324330    psMemSetDeallocator(p, (psFreeFunc) projectionFree);
     
    368374      case PS_PROJ_ZEA:
    369375      case PS_PROJ_ZPL:
     376      case PS_PROJ_ZPN:
    370377        class = PS_PROJECTION_CLASS_ZENITHAL;
    371378        break;
     
    442449            out->y = -zeta * cosPhiCT;
    443450            break;
     451
     452          case PS_PROJ_ZPN: {
     453            // the forward projection is:
     454            // theta = atan2(stht, ctht)
     455            // gamma = (pi/2 - theta) : theta in radians
     456            // Ro = sum (P_i gamma^i)
     457            // R  = (180/pi) Ro
     458           
     459            // Ro = (pi/180)(90 - theta)
     460            // R = (180/pi)sum (P_i R^i)
     461           
     462            // is ZPN defined for Npolyterms = 0 or 1?
     463
     464            double cosTheta = hypot(sinPhiCT, cosPhiCT);
     465            double theta = atan2 (sinTheta, cosTheta);
     466           
     467            double gamma = M_PI_2 - theta;
     468           
     469            // i = 0 .. N - 1 (1 <= Npolyterms <= 21)
     470            double Ro = 0.0;
     471            for (int i = projection->radial->n - 1; i > 0; i--) {
     472              double Pi = projection->radial->data.F64[i];
     473              Ro = (Ro + Pi)*gamma;
     474            }
     475            Ro += projection->radial->data.F64[0];
     476           
     477            out->x = (cosTheta == 0.0) ? 0.0 : +Ro * sinPhiCT / cosTheta ;
     478            out->y = (cosTheta == 0.0) ? 0.0 : -Ro * cosPhiCT / cosTheta ;
     479            break;
     480          }
     481
    444482          default:
    445483            psAbort("invalid projection");
     
    525563      case PS_PROJ_ZEA:
    526564      case PS_PROJ_ZPL:
     565      case PS_PROJ_ZPN:
    527566        class = PS_PROJECTION_CLASS_ZENITHAL;
    528567        break;
     
    574613          case PS_PROJ_SIN:
    575614            // Orhtographic deprojection
     615            cosTheta = R;
    576616            sinTheta = sqrt (1 - R*R);
    577             cosTheta = R;
    578617            break;
    579618          case PS_PROJ_STG:
    580             psAbort("STG not defined");
     619            sinTheta = (4 - R) / (4 + R);
     620            cosTheta = sqrt (1 - sinTheta*sinTheta);
    581621            break;
    582622          case PS_PROJ_ZEA:
     
    587627            cosTheta = sqrt (1 - PS_SQR(sinTheta));
    588628            break;
     629
     630      case PS_PROJ_ZPN:
     631
     632        // the forward projection is:
     633        // theta = atan2(stht, ctht)
     634        // gamma = (pi/2 - theta) : theta in radians
     635        // Ro = sum (P_i gamma^i)
     636        // R  = (180/pi) Ro
     637
     638        // given R, we need to find theta:
     639        // Ro = R * (pi / 180) = sum (P_i gamma^i)
     640        // solve sum (P_i gamma^i) - Ro = 0 using Newton-Raphson
     641
     642        // use Ro to get a guess for gamma and iterate
     643
     644        {
     645          // find the roots of f(gamma) - R = 0
     646          // starting guess for gamma is (R - P0) / P1
     647          double gamma = (R - projection->radial->data.F64[0]) / projection->radial->data.F64[1];
     648         
     649          for (int iter = 0; iter < 5; iter++) {
     650           
     651            double Rc = 0.0; // this will hold the ander
     652            double dR = 0.0;
     653            for (int i = projection->radial->n - 1; i > 1; i--) {
     654              double Pi = projection->radial->data.F64[i];
     655              Rc = (Rc + Pi)*gamma;
     656              dR = (dR + i*Pi)*gamma;
     657            }
     658            double P0 = projection->radial->data.F64[0];
     659            double P1 = projection->radial->data.F64[1];
     660            Rc = (Rc + P1)*gamma + P0;
     661            dR = (dR + P1);
     662
     663            double gamma_new = gamma - (Rc - R) / dR;
     664            gamma = gamma_new;
     665          }
     666         
     667          double theta = M_PI_2 - gamma ;
     668          cosTheta = cos (theta);
     669          sinTheta = sin (theta);
     670          break;
     671        }
     672       
    589673          default:
    590674            psAbort("invalid projection");
     
    9491033        myPT = psPlaneTransformAlloc(order, order);
    9501034    } else {
     1035      // the user has supplied a model with a specific order : fit that order
     1036      myPT = psMemIncrRefCounter(out); // we need to return something which can be freed
     1037# if (0)
    9511038        if ((out->x->nX == order) && (out->x->nY == order) &&
    9521039            (out->y->nX == order) && (out->y->nX == order)) {
     
    9561043            myPT = psPlaneTransformAlloc(order, order);
    9571044        }
     1045# endif
    9581046    }
    9591047
     
    11831271
    11841272    switch (type) {
    1185       case PS_PROJ_LIN:
    1186         psStringAppend (&name, "%s-LIN", prefix);
    1187         return name;
    1188       case PS_PROJ_PLY:
    1189         psStringAppend (&name, "%s-PLY", prefix);
    1190         return name;
    1191       case PS_PROJ_WRP:
    1192         psStringAppend (&name, "%s-WRP", prefix);
    1193         return name;
    1194       case PS_PROJ_TAN:
    1195         psStringAppend (&name, "%s-TAN", prefix);
    1196         return name;
    1197       case PS_PROJ_TNX:
    1198         psStringAppend (&name, "%s-TNX", prefix);
    1199         return name;
    1200       case PS_PROJ_DIS:
    1201         psStringAppend (&name, "%s-DIS", prefix);
    1202         return name;
    1203       case PS_PROJ_SIN:
    1204         psStringAppend (&name, "%s-SIN", prefix);
    1205         return name;
    1206       case PS_PROJ_STG:
    1207         psStringAppend (&name, "%s-STG", prefix);
    1208         return name;
    1209       case PS_PROJ_AIT:
    1210         psStringAppend (&name, "%s-AIT", prefix);
    1211         return name;
    1212       case PS_PROJ_PAR:
    1213         psStringAppend (&name, "%s-PAR", prefix);
    1214         return name;
    1215       case PS_PROJ_GLS:
    1216         psStringAppend (&name, "%s-GLS", prefix);
    1217         return name;
    1218       case PS_PROJ_CAR:
    1219         psStringAppend (&name, "%s-CAR", prefix);
    1220         return name;
    1221       case PS_PROJ_MER:
    1222         psStringAppend (&name, "%s-MER", prefix);
    1223         return name;
     1273      case PS_PROJ_LIN: psStringAppend (&name, "%s-LIN", prefix); return name;
     1274      case PS_PROJ_PLY: psStringAppend (&name, "%s-PLY", prefix); return name;
     1275      case PS_PROJ_WRP: psStringAppend (&name, "%s-WRP", prefix); return name;
     1276      case PS_PROJ_TAN: psStringAppend (&name, "%s-TAN", prefix); return name;
     1277
     1278      case PS_PROJ_DIS: psStringAppend (&name, "%s-DIS", prefix); return name;
     1279      case PS_PROJ_SIN: psStringAppend (&name, "%s-SIN", prefix); return name;
     1280      case PS_PROJ_STG: psStringAppend (&name, "%s-STG", prefix); return name;
     1281      case PS_PROJ_TNX: psStringAppend (&name, "%s-TNX", prefix); return name;
     1282
     1283      case PS_PROJ_ZEA: psStringAppend (&name, "%s-ZEA", prefix); return name;
     1284      case PS_PROJ_ZPL: psStringAppend (&name, "%s-ZPL", prefix); return name;
     1285      case PS_PROJ_ZPN: psStringAppend (&name, "%s-ZPN", prefix); return name;
     1286      case PS_PROJ_AIT: psStringAppend (&name, "%s-AIT", prefix); return name;
     1287
     1288      case PS_PROJ_PAR: psStringAppend (&name, "%s-PAR", prefix); return name;
     1289      case PS_PROJ_GLS: psStringAppend (&name, "%s-GLS", prefix); return name;
     1290      case PS_PROJ_CAR: psStringAppend (&name, "%s-CAR", prefix); return name;
     1291      case PS_PROJ_MER: psStringAppend (&name, "%s-MER", prefix); return name;
    12241292
    12251293      default:
     
    12381306    if (!strcmp (&name[4], "-WRP")) return PS_PROJ_WRP;
    12391307    if (!strcmp (&name[4], "-TAN")) return PS_PROJ_TAN;
    1240     if (!strcmp (&name[4], "-TNX")) return PS_PROJ_TNX;
    12411308    if (!strcmp (&name[4], "-DIS")) return PS_PROJ_DIS;
    12421309    if (!strcmp (&name[4], "-SIN")) return PS_PROJ_SIN;
    12431310    if (!strcmp (&name[4], "-STG")) return PS_PROJ_STG;
     1311    if (!strcmp (&name[4], "-TNX")) return PS_PROJ_TNX;
     1312    if (!strcmp (&name[4], "-ZEA")) return PS_PROJ_ZEA;
     1313    if (!strcmp (&name[4], "-ZPL")) return PS_PROJ_ZPL;
     1314    if (!strcmp (&name[4], "-ZPN")) return PS_PROJ_ZPN;
    12441315    if (!strcmp (&name[4], "-AIT")) return PS_PROJ_AIT;
    12451316    if (!strcmp (&name[4], "-PAR")) return PS_PROJ_PAR;
  • trunk/psLib/src/astro/psCoord.h

    r14452 r39926  
    130130    PS_PROJ_ZEA,                        ///< Sine projection
    131131    PS_PROJ_ZPL,                        ///< Sine projection
     132    PS_PROJ_ZPN,                        ///< Sine projection
    132133    PS_PROJ_AIT,                        ///< Aitoff projection
    133134    PS_PROJ_PAR,                        ///< Par projection
     
    150151    double Ys;                         ///< plate-scale in Y direction
    151152    psProjectionType type;             ///< Projection type
    152 }
    153 psProjection;
     153    psVector *radial;          ///< radial distortion terms
     154} psProjection;
    154155
    155156/** Allocates a psPlane
  • trunk/psLib/src/fits/psFitsScale.c

    r39509 r39926  
    189189                // Desperate retry
    190190                mean = psStatsGetValue(stats, DESPERATE_MEAN_STAT);
    191                 stdev = psStatsGetValue(stats, DESPERATE_STDEV_STAT);
     191                if ((STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     192                  stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ);
     193                }
     194                else {
     195                  stdev = psStatsGetValue(stats, DESPERATE_STDEV_STAT);
     196                }
    192197            }
    193198        } else {
    194199            // Retry with all available pixels
    195200            mean = psStatsGetValue(stats, MEAN_STAT);
    196             stdev = psStatsGetValue(stats, STDEV_STAT);
     201            if ((STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     202              stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ);
     203            }
     204            else {
     205              stdev = psStatsGetValue(stats, STDEV_STAT);
     206            }
    197207        }
    198208    } else {
    199209        // First attempt
    200210        mean = psStatsGetValue(stats, MEAN_STAT);
    201         stdev = psStatsGetValue(stats, STDEV_STAT);
     211        if ((STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     212          stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ);
     213        }
     214        else {
     215          stdev = psStatsGetValue(stats, STDEV_STAT);
     216        }
    202217    }
    203218    psFree(rng);
     
    554569                // Desperate retry
    555570                mean = psStatsGetValue(stats, DESPERATE_MEAN_STAT);
    556                 stdev = psStatsGetValue(stats, DESPERATE_STDEV_STAT);
    557             }
     571                if ((DESPERATE_STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(DESPERATE_STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     572                  stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ); // Calculate a "sigma" based on the interquartile distance.
     573                }
     574                else {
     575                 
     576                  stdev = psStatsGetValue(stats, DESPERATE_STDEV_STAT);
     577                }
     578            }   
    558579        } else {
    559580            // Retry with all available pixels
    560581            mean = psStatsGetValue(stats, MEAN_STAT);
    561             stdev = psStatsGetValue(stats, STDEV_STAT);
     582            if ((STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     583              stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ); // Calculate a "sigma" based on the interquartile distance.
     584            }
     585            else {
     586              stdev = psStatsGetValue(stats, STDEV_STAT);
     587            }
    562588        }
    563589    } else {
    564590        // First attempt
    565591        mean = psStatsGetValue(stats, MEAN_STAT);
    566         stdev = psStatsGetValue(stats, STDEV_STAT);
     592        if ((STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     593          stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ); // Calculate a "sigma" based on the interquartile distance.
     594        }
     595        else {
     596          stdev = psStatsGetValue(stats, STDEV_STAT);
     597        }
    567598    }
    568599    psFree(rng);
     
    723754                // Desperate retry
    724755                mean = psStatsGetValue(stats, DESPERATE_MEAN_STAT);
    725                 stdev = psStatsGetValue(stats, DESPERATE_STDEV_STAT);
     756                if ((DESPERATE_STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(DESPERATE_STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     757                  stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ); // Calculate a "sigma" based on the interquartile distance.
     758                }
     759                else {
     760                  stdev = psStatsGetValue(stats, DESPERATE_STDEV_STAT);
     761                }
    726762            }
    727763        } else {
    728764            // Retry with all available pixels
    729765            mean = psStatsGetValue(stats, MEAN_STAT);
    730             stdev = psStatsGetValue(stats, STDEV_STAT);
     766            if ((STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     767              stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ); // Calculate a "sigma" based on the interquartile distance.
     768            }
     769            else {
     770              stdev = psStatsGetValue(stats, STDEV_STAT);
     771            }
    731772        }
    732773    } else {
    733774        // First attempt
    734775        mean = psStatsGetValue(stats, MEAN_STAT);
    735         stdev = psStatsGetValue(stats, STDEV_STAT);
     776        if ((STDEV_STAT == PS_STAT_SAMPLE_QUARTILE)||(STDEV_STAT == PS_STAT_ROBUST_QUARTILE)) {
     777          stdev = 0.7415 * (stats->sampleUQ - stats->sampleLQ); // Calculate a "sigma" based on the interquartile distance.
     778        }
     779        else {
     780          stdev = psStatsGetValue(stats, STDEV_STAT);
     781        }
    736782    }
    737783    psFree(rng);
  • trunk/psLib/src/types/psMetadata.c

    r39598 r39926  
    13901390            break;
    13911391        case PS_DATA_F64:
    1392             fprintf(fd, "%f\n", item->data.F64);
     1392            fprintf(fd, "%g\n", item->data.F64);
    13931393            break;
    13941394        case PS_DATA_METADATA:
  • trunk/psModules/src/astrom/pmAstrometryDistortion.c

    r23989 r39926  
    335335
    336336    psFree (fpa->fromTPA);
    337     fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *region, 50);
     337    psPlaneTransform *myPT = psPlaneTransformAlloc(fpa->toTPA->x->nX+4, fpa->toTPA->x->nY+4);
     338    fpa->fromTPA = psPlaneTransformInvert(myPT, fpa->toTPA, *region, 50);
     339    psFree (myPT);
    338340    psFree (region);
    339341
  • trunk/psModules/src/astrom/pmAstrometryModel.c

    r36834 r39926  
    320320    // the PosZero is the offset between the reported and actual POSANGLE values
    321321    float PosZero = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.POS_ZERO");  /// XXX be consistent with degrees v radians
     322    // Indicate which direction the position angle goes
     323    int rotParity = psMetadataLookupS32 (&status, file->fpa->concepts, "FPA.ROT_PARITY");
    322324    char *refChip = psMetadataLookupStr (&status, file->fpa->concepts, "FPA.REF.CHIP");
    323325
     
    349351
    350352    psMetadataAddF32(row,    PS_LIST_TAIL, "POS_ZERO", PS_META_REPLACE, "POSANGLE offset (degrees)", PosZero);
     353    psMetadataAddS32(row,    PS_LIST_TAIL, "ROT_PARITY", PS_META_REPLACE, "rotator parity", rotParity);
    351354    psMetadataAddStr(row,    PS_LIST_TAIL, "REF_CHIP", PS_META_REPLACE, "reference chip for model", refChip);
    352355
     
    624627    TRANSFER (file->fpa->concepts, row, "BORE_P0");
    625628    TRANSFER (file->fpa->concepts, row, "POS_ZERO");
     629    TRANSFER (file->fpa->concepts, row, "ROT_PARITY");
    626630    TRANSFER (file->fpa->concepts, row, "REF_CHIP");
    627631
     
    687691    char *refChip  = psMetadataLookupStr(&status, file->fpa->concepts, "REF_CHIP"); REQUIRE (status, "missing REF_CHIP");
    688692
     693    int rotatorParity = psMetadataLookupS32(&status, file->fpa->concepts, "ROT_PARITY"); REQUIRE (status, "missing ROT_PARITY");
     694   
    689695    // XXX we've swapped the sign and parity of POS (add to model)
    690696    // apply true posangle = -(POS - POS_ZERO)
    691697    psLogMsg ("psModules.astrom", 4, "Position Angle: %f, Model Position Angle Zero Point: %f\n", POS, PosZero);
    692     psPlaneTransform *fromTPA = psPlaneTransformRotate (NULL, file->fpa->fromTPA, (PosZero - POS));
     698    psPlaneTransform *fromTPA = psPlaneTransformRotate (NULL, file->fpa->fromTPA, rotatorParity * (PosZero - POS));
    693699    psFree (file->fpa->fromTPA);
    694700    file->fpa->fromTPA = fromTPA;
  • trunk/psModules/src/astrom/pmAstrometryObjects.c

    r36834 r39926  
    225225    psArray *ref,
    226226    psArray *match,
    227     psStats *stats)
     227    psStats *stats,
     228    const psMetadata *config)
    228229{
    229230    PS_ASSERT_PTR_NON_NULL(map, NULL);
     
    232233    PS_ASSERT_PTR_NON_NULL(match, NULL);
    233234    PS_ASSERT_PTR_NON_NULL(stats, NULL);
     235    PS_ASSERT_PTR_NON_NULL(config, NULL);
     236
     237    // sigma of gaussian window to down-weight photometric outliers (ignored if NAN or 0.0)
     238    bool status;
     239    double photomWindowSigma  = psMetadataLookupF32 (&status, config, "PSASTRO.PHOTOM.WINDOW.SIGMA");
     240    bool   photomWindowApply  = !(isnan(photomWindowSigma) || (fabs(photomWindowSigma) < 0.01));
     241    double photomWindowFactor = photomWindowApply ? -0.5/PS_SQR(photomWindowSigma) : 0.0;
    234242
    235243    // reassign values for clip fit
     
    252260        y->data.F32[i] = refStar->FP->y;
    253261
    254         wt->data.F32[i] = 1.0;
     262        // wt is used as an error (sqrt(variance)) in the fit. the 1.01 prevents the weight from going to 0.0 for perfect matches
     263        wt->data.F32[i] = 1.01 - exp(photomWindowFactor*PS_SQR(refStar->magCal - rawStar->magCal));
    255264    }
    256265
     
    657666    obj->Color= 0;
    658667    obj->dMag = 0;
     668    obj->magCal = 0;
    659669
    660670    return (obj);
     
    685695    obj->Color =  old->Color;
    686696    obj->dMag  =  old->dMag;
     697    obj->magCal =  old->magCal;
    687698
    688699    return(obj);
     
    774785    double gridOffset = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.OFFSET");
    775786
    776     // sampling scale of the grid
    777     double gridScale  = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.SCALE");
     787     // sampling scale of the grid
     788     double gridScale  = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.SCALE");
     789
     790    // sigma of gaussian window to down-weight photometric outliers (ignored if NAN or 0.0)
     791    double photomWindowSigma  = psMetadataLookupF32 (&status, config, "PSASTRO.PHOTOM.WINDOW.SIGMA");
     792    bool   photomWindowApply  = !(isnan(photomWindowSigma) || (fabs(photomWindowSigma) < 0.01));
     793    double photomWindowFactor = photomWindowApply ? -0.5/PS_SQR(photomWindowSigma) : 0.0;
    778794
    779795    // set the static scaling factors
     
    816832            }
    817833
     834            // XXX should I make the scale factor in front a recipe value?
     835            int Npts = 10 * exp(photomWindowFactor*PS_SQR(ob1->magCal - ob2->magCal));
     836
    818837            // accumulate bin stats
    819             NP[iY][iX] ++;
    820             DX[iY][iX] += dX;
    821             DY[iY][iX] += dY;
    822             D2[iY][iX] += PS_SQR(dX) + PS_SQR(dY);
     838            NP[iY][iX] += Npts;
     839            DX[iY][iX] += dX*Npts;
     840            DY[iY][iX] += dY*Npts;
     841            D2[iY][iX] += PS_SQR(dX*Npts) + PS_SQR(dY*Npts);
    823842        }
    824843    }
     
    10531072    double tweakNsigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.TWEAK.NSIGMA");
    10541073
     1074    // sigma of gaussian window to down-weight photometric outliers (ignored if NAN or 0.0)
     1075    double photomWindowSigma  = psMetadataLookupF32 (&status, recipe, "PSASTRO.PHOTOM.WINDOW.SIGMA");
     1076    bool   photomWindowApply  = !(isnan(photomWindowSigma) || (fabs(photomWindowSigma) < 0.01));
     1077    double photomWindowFactor = photomWindowApply ? -0.5/PS_SQR(photomWindowSigma) : 0.0;
     1078
    10551079    nBin = 2*tweakRange / tweakScale;
    10561080    psVector *xHist = psVectorAlloc (nBin, PS_TYPE_F32);
     
    10791103                continue;
    10801104
    1081             xHist->data.F32[xBin] += 1.0;
    1082             yHist->data.F32[yBin] += 1.0;
     1105            // XXX should I make the scale factor in front a recipe value?
     1106            int Npts = 10 * exp(photomWindowFactor*PS_SQR(ob1->magCal - ob2->magCal));  // sigma = 0.22 mag
     1107
     1108            xHist->data.F32[xBin] += Npts;
     1109            yHist->data.F32[yBin] += Npts;
    10831110        }
    10841111    }
  • trunk/psModules/src/astrom/pmAstrometryObjects.h

    r36834 r39926  
    4343    float dMag;                         ///< error on object magnitude
    4444    float SBinst;                       ///< surface brightness, used for Koppenhoefer correction
     45    float magCal;                       ///< object calibrated magnitude in extracted filter
    4546}
    4647pmAstromObj;
     
    347348    psArray *ref,
    348349    psArray *match,
    349     psStats *stats
     350    psStats *stats,
     351    const psMetadata *config
    350352);
    351353
  • trunk/psModules/src/astrom/pmAstrometryWCS.c

    r36492 r39926  
    4343    pmAstromWCS *wcs = pmAstromWCSfromHeader (header);
    4444    if (!wcs) {
    45         return false;
     45        return false;
    4646    }
    4747
     
    7070    pmAstromWCS *wcs = pmAstromWCSfromHeader (header);
    7171    if (!wcs) {
    72         return false;
     72        return false;
    7373    }
    7474
     
    8686    pmAstromWCS *wcs = pmAstromWCSfromHeader (header);
    8787    if (!wcs) {
    88         psError(PS_ERR_UNKNOWN, false, "failure to determine WCS terms from header");
    89         return false;
     88        psError(PS_ERR_UNKNOWN, false, "failure to determine WCS terms from header");
     89        return false;
    9090    }
    9191
     
    9696
    9797    if (!status1 || !status2) {
    98         Nx = psMetadataLookupS32 (&status1, header, "IMNAXIS1");
    99         Ny = psMetadataLookupS32 (&status2, header, "IMNAXIS2");
     98        Nx = psMetadataLookupS32 (&status1, header, "IMNAXIS1");
     99        Ny = psMetadataLookupS32 (&status2, header, "IMNAXIS2");
    100100    }
    101101
    102102    if (!status1 || !status2) {
    103         Nx = psMetadataLookupS32 (&status1, header, "ZNAXIS1");
    104         Ny = psMetadataLookupS32 (&status2, header, "ZNAXIS2");
     103        Nx = psMetadataLookupS32 (&status1, header, "ZNAXIS1");
     104        Ny = psMetadataLookupS32 (&status2, header, "ZNAXIS2");
    105105    }
    106106
    107107    if (!status1 || !status2) {
    108         psFree (wcs);
    109         psError(PS_ERR_UNKNOWN, false, "missing required FPA size in header");
    110         return false;
     108        psFree (wcs);
     109        psError(PS_ERR_UNKNOWN, false, "missing required FPA size in header");
     110        return false;
    111111    }
    112112
     
    123123    pmAstromWCS *wcs = pmAstromWCSBilevelChipFromFPA (chip, tol);
    124124    if (!wcs) {
    125         psError(PS_ERR_UNKNOWN, false, "failure to determine WCS terms from fpa");
    126         return false;
     125        psError(PS_ERR_UNKNOWN, false, "failure to determine WCS terms from fpa");
     126        return false;
    127127    }
    128128
     
    139139    pmAstromWCS *wcs = pmAstromWCSBilevelMosaicFromFPA (fpa, tol);
    140140    if (!wcs) {
    141         psError(PS_ERR_UNKNOWN, false, "failure to determine WCS terms from fpa");
    142         return false;
     141        psError(PS_ERR_UNKNOWN, false, "failure to determine WCS terms from fpa");
     142        return false;
    143143    }
    144144
     
    163163
    164164    if (chip == NULL)
    165         return false;
     165        return false;
    166166    if (sky == NULL)
    167         return false;
     167        return false;
    168168    if (wcs == NULL)
    169         return false;
     169        return false;
    170170
    171171    psPlane *Chip = psPlaneAlloc();
     
    188188
    189189    if (chip == NULL)
    190         return false;
     190        return false;
    191191    if (sky == NULL)
    192         return false;
     192        return false;
    193193    if (wcs == NULL)
    194         return false;
     194        return false;
    195195
    196196    psError(PS_ERR_UNKNOWN, true, "not yet implemented: needs to invert the transformation");
     
    223223    char *ctype = psMetadataLookupPtr (&status, header, "CTYPE2");
    224224    if (!status) {
    225         psLogMsg ("psastro", 5, "warning: no WCS metadata in header\n");
    226         return NULL;
     225        psLogMsg ("psastro", 5, "warning: no WCS metadata in header\n");
     226        return NULL;
    227227    }
    228228
     
    232232    type = psProjectTypeFromString (ctype);
    233233    if (type == PS_PROJ_NTYPE) {
    234         psLogMsg ("psastro", 2, "warning: unknown projection type %s\n", ctype);
    235         return NULL;
     234        psLogMsg ("psastro", 2, "warning: unknown projection type %s\n", ctype);
     235        return NULL;
    236236    }
    237237
     
    243243
    244244    if (cdKeys && pcKeys) {
    245         // XXX make this an option
    246         psLogMsg ("psastro", 5, "warning: both CDi_j and PC00i00j defined in headers, using PC00i00j terms\n");
     245        // XXX make this an option
     246        psLogMsg ("psastro", 5, "warning: both CDi_j and PC00i00j defined in headers, using PC00i00j terms\n");
    247247    }
    248248    if (!cdKeys && !pcKeys) {
    249         psError(PS_ERR_UNKNOWN, true, "missing both CDi_j and PC00i00j WCS terms");
    250         // XXX we could default here to RA, DEC, ROTANGLE
    251         return NULL;
     249        psError(PS_ERR_UNKNOWN, true, "missing both CDi_j and PC00i00j WCS terms");
     250        // XXX we could default here to RA, DEC, ROTANGLE
     251        return NULL;
    252252    }
    253253    if (isPoly) {
    254         if (!pcKeys) {
    255             psError(PS_ERR_UNKNOWN, true, "polynomial terms defined, but missing PC00i00j WCS terms");
    256             return NULL;
    257         }
    258         if (fitOrder == 0)
    259             fitOrder = 1;
    260         if ((fitOrder > 3) || (fitOrder < 1)) {
    261             psError(PS_ERR_UNKNOWN, true, "NPLYTERM value undefined: %d", fitOrder);
    262             return NULL;
    263         }
     254        if (!pcKeys) {
     255            psError(PS_ERR_UNKNOWN, true, "polynomial terms defined, but missing PC00i00j WCS terms");
     256            return NULL;
     257        }
     258        if (fitOrder == 0)
     259            fitOrder = 1;
     260        if ((fitOrder > 3) || (fitOrder < 1)) {
     261            psError(PS_ERR_UNKNOWN, true, "NPLYTERM value undefined: %d", fitOrder);
     262            return NULL;
     263        }
    264264    } else {
    265         fitOrder = 1;
     265        fitOrder = 1;
    266266    }
    267267
     
    277277    wcs->crpix2 = psMetadataLookupF64 (&status, header, "CRPIX2");
    278278    wcs->toSky = psProjectionAlloc (wcs->crval1*PM_RAD_DEG, wcs->crval2*PM_RAD_DEG, PM_RAD_DEG, PM_RAD_DEG, type);
     279
     280    // XXX if type == ZPN, look for PV2_%d elements:
     281    if (type == PS_PROJ_ZPN) {
     282        psVector *maxRadial = psVectorAlloc (21, PS_TYPE_F64);
     283        for (int i = 0; i <= 20; i++) {
     284            char name[64];
     285            snprintf (name, 64, "PV2_%d", i);
     286
     287            maxRadial->data.F64[i] = 0.0;
     288            double value = psMetadataLookupF64 (&status, header, name);
     289
     290            if (status) {
     291                maxRadial->data.F64[i] = value;
     292                maxRadial->n = i;
     293            }
     294
     295            // PV2_1 is implicit if not present
     296            if ((i == 1) && !status) {
     297                maxRadial->data.F64[i] = 1.0;
     298                continue;
     299            }
     300        }
     301        maxRadial->n ++;
     302        wcs->toSky->radial = maxRadial;
     303    }
    279304
    280305    // These aren't needed but having them empty is disconcerting
     
    289314    // test the CDELTi varient
    290315    if (pcKeys) {
    291         wcs->wcsCDkeys = 0;
    292         wcs->cdelt1 = psMetadataLookupF64 (&status, header, "CDELT1");
    293         wcs->cdelt2 = psMetadataLookupF64 (&status, header, "CDELT2");
    294 
    295         // test the CROTAi varient:
    296         // XXX double check lambda..
    297         double rotate = psMetadataLookupF64 (&status, header, "CROTA2");
    298         if (status) {
    299             wcs->trans->x->coeff[1][0] = +wcs->cdelt1 * cos(rotate*PM_RAD_DEG); // == PC1_1
    300             wcs->trans->x->coeff[0][1] = -wcs->cdelt2 * sin(rotate*PM_RAD_DEG); // == PC1_2
    301             wcs->trans->y->coeff[1][0] = +wcs->cdelt1 * sin(rotate*PM_RAD_DEG); // == PC2_1
    302             wcs->trans->y->coeff[0][1] = +wcs->cdelt2 * cos(rotate*PM_RAD_DEG); // == PC2_2
    303             return wcs;
    304         }
    305 
    306         // FITS WCS PCi,j has units of unity
    307         // wcs->trans has units of degrees/pixel
    308         wcs->trans->x->coeff[1][0] = wcs->cdelt1 * psMetadataLookupF64 (&status, header, "PC001001"); // == PC1_1
    309         wcs->trans->x->coeff[0][1] = wcs->cdelt2 * psMetadataLookupF64 (&status, header, "PC001002"); // == PC1_2
    310         wcs->trans->y->coeff[1][0] = wcs->cdelt1 * psMetadataLookupF64 (&status, header, "PC002001"); // == PC2_1
    311         wcs->trans->y->coeff[0][1] = wcs->cdelt2 * psMetadataLookupF64 (&status, header, "PC002002"); // == PC2_2
    312 
    313         if (isPoly) {
    314             // Elixir-style polynomial terms
    315             // XXX currently, Elixir/DVO cannot accept mixed orders
    316             for (int i = 0; i <= fitOrder; i++) {
    317                 for (int j = 0; j <= fitOrder; j++) {
    318                     if (i + j < 2)
    319                         continue;
    320                     if (i + j > fitOrder) {
    321                         wcs->trans->x->coeffMask[i][j] = PS_POLY_MASK_SET;
    322                         wcs->trans->y->coeffMask[i][j] = PS_POLY_MASK_SET;
    323                         continue;
    324                     }
    325                     sprintf (name, "PCA1X%1dY%1d", i, j);
    326                     wcs->trans->x->coeff[i][j] = pow(wcs->cdelt1, i) * pow(wcs->cdelt2, j) * psMetadataLookupF64 (&status, header, name);
    327                     sprintf (name, "PCA2X%1dY%1d", i, j);
    328                     wcs->trans->y->coeff[i][j] = pow(wcs->cdelt1, i) * pow(wcs->cdelt2, j) * psMetadataLookupF64 (&status, header, name);
    329                 }
    330             }
    331         }
    332         return wcs;
     316        wcs->wcsCDkeys = 0;
     317        wcs->cdelt1 = psMetadataLookupF64 (&status, header, "CDELT1");
     318        wcs->cdelt2 = psMetadataLookupF64 (&status, header, "CDELT2");
     319
     320        // test the CROTAi varient:
     321        // XXX double check lambda..
     322        double rotate = psMetadataLookupF64 (&status, header, "CROTA2");
     323        if (status) {
     324            wcs->trans->x->coeff[1][0] = +wcs->cdelt1 * cos(rotate*PM_RAD_DEG); // == PC1_1
     325            wcs->trans->x->coeff[0][1] = -wcs->cdelt2 * sin(rotate*PM_RAD_DEG); // == PC1_2
     326            wcs->trans->y->coeff[1][0] = +wcs->cdelt1 * sin(rotate*PM_RAD_DEG); // == PC2_1
     327            wcs->trans->y->coeff[0][1] = +wcs->cdelt2 * cos(rotate*PM_RAD_DEG); // == PC2_2
     328            return wcs;
     329        }
     330
     331        // FITS WCS PCi,j has units of unity
     332        // wcs->trans has units of degrees/pixel
     333        wcs->trans->x->coeff[1][0] = wcs->cdelt1 * psMetadataLookupF64 (&status, header, "PC001001"); // == PC1_1
     334        wcs->trans->x->coeff[0][1] = wcs->cdelt2 * psMetadataLookupF64 (&status, header, "PC001002"); // == PC1_2
     335        wcs->trans->y->coeff[1][0] = wcs->cdelt1 * psMetadataLookupF64 (&status, header, "PC002001"); // == PC2_1
     336        wcs->trans->y->coeff[0][1] = wcs->cdelt2 * psMetadataLookupF64 (&status, header, "PC002002"); // == PC2_2
     337
     338        if (isPoly) {
     339            // Elixir-style polynomial terms
     340            // XXX currently, Elixir/DVO cannot accept mixed orders
     341            for (int i = 0; i <= fitOrder; i++) {
     342                for (int j = 0; j <= fitOrder; j++) {
     343                    if (i + j < 2)
     344                        continue;
     345                    if (i + j > fitOrder) {
     346                        wcs->trans->x->coeffMask[i][j] = PS_POLY_MASK_SET;
     347                        wcs->trans->y->coeffMask[i][j] = PS_POLY_MASK_SET;
     348                        continue;
     349                    }
     350                    sprintf (name, "PCA1X%1dY%1d", i, j);
     351                    wcs->trans->x->coeff[i][j] = pow(wcs->cdelt1, i) * pow(wcs->cdelt2, j) * psMetadataLookupF64 (&status, header, name);
     352                    sprintf (name, "PCA2X%1dY%1d", i, j);
     353                    wcs->trans->y->coeff[i][j] = pow(wcs->cdelt1, i) * pow(wcs->cdelt2, j) * psMetadataLookupF64 (&status, header, name);
     354                }
     355            }
     356        }
     357        return wcs;
    333358    }
    334359
    335360    // test the CDi_j varient
    336361    if (cdKeys) {
    337         wcs->wcsCDkeys = 1;
    338 
    339         wcs->trans->x->coeff[1][0] = psMetadataLookupF64 (&status, header, "CD1_1"); // == PC1_1
    340         wcs->trans->x->coeff[0][1] = psMetadataLookupF64 (&status, header, "CD1_2"); // == PC1_2
    341         wcs->trans->y->coeff[1][0] = psMetadataLookupF64 (&status, header, "CD2_1"); // == PC2_1
    342         wcs->trans->y->coeff[0][1] = psMetadataLookupF64 (&status, header, "CD2_2"); // == PC2_2
    343         wcs->cdelt1 = hypot (wcs->trans->x->coeff[1][0], wcs->trans->x->coeff[0][1]);
    344         wcs->cdelt2 = hypot (wcs->trans->y->coeff[1][0], wcs->trans->y->coeff[0][1]);
    345         return wcs;
     362        wcs->wcsCDkeys = 1;
     363
     364        wcs->trans->x->coeff[1][0] = psMetadataLookupF64 (&status, header, "CD1_1"); // == PC1_1
     365        wcs->trans->x->coeff[0][1] = psMetadataLookupF64 (&status, header, "CD1_2"); // == PC1_2
     366        wcs->trans->y->coeff[1][0] = psMetadataLookupF64 (&status, header, "CD2_1"); // == PC2_1
     367        wcs->trans->y->coeff[0][1] = psMetadataLookupF64 (&status, header, "CD2_2"); // == PC2_2
     368        wcs->cdelt1 = hypot (wcs->trans->x->coeff[1][0], wcs->trans->x->coeff[0][1]);
     369        wcs->cdelt2 = hypot (wcs->trans->y->coeff[1][0], wcs->trans->y->coeff[0][1]);
     370        return wcs;
    346371    }
    347372    psLogMsg ("psastro", 2, "warning: missing rotation matrix?\n");
     
    376401    psMetadataAddF64 (header, PS_LIST_TAIL, "CRPIX2", PS_META_REPLACE, "", wcs->crpix2);
    377402
     403    if (wcs->toSky->type == PS_PROJ_ZPN) {
     404        psAssert (wcs->toSky->radial, "missing radial vector");
     405        for (int i = 0; i < wcs->toSky->radial->n; i++) {
     406            if (wcs->toSky->radial->data.F64[i] == 0.0) continue;
     407            snprintf (name, 16, "PV2_%d", i);
     408            psMetadataAddF64 (header, PS_LIST_TAIL, name, PS_META_REPLACE, "", wcs->toSky->radial->data.F64[i]);
     409        }
     410    }
     411
    378412    // XXX make it optional to write out CDi_j terms, or other versions
    379413    // apply CDELT1,2 (degrees / pixel) to yield PCi,j terms of order unity
    380414    if (!wcs->wcsCDkeys) {
    381415
    382       double cdelt1 = wcs->cdelt1;
    383       double cdelt2 = wcs->cdelt2;
    384       psMetadataAddF64 (header, PS_LIST_TAIL, "CDELT1", PS_META_REPLACE, "", cdelt1);
    385       psMetadataAddF64 (header, PS_LIST_TAIL, "CDELT2", PS_META_REPLACE, "", cdelt2);
    386 
    387       // test the PC00i00j varient:
    388       psMetadataAddF64 (header, PS_LIST_TAIL, "PC001001", PS_META_REPLACE, "", wcs->trans->x->coeff[1][0] / cdelt1); // == PC1_1
    389       psMetadataAddF64 (header, PS_LIST_TAIL, "PC001002", PS_META_REPLACE, "", wcs->trans->x->coeff[0][1] / cdelt2); // == PC1_2
    390       psMetadataAddF64 (header, PS_LIST_TAIL, "PC002001", PS_META_REPLACE, "", wcs->trans->y->coeff[1][0] / cdelt1); // == PC2_1
    391       psMetadataAddF64 (header, PS_LIST_TAIL, "PC002002", PS_META_REPLACE, "", wcs->trans->y->coeff[0][1] / cdelt2); // == PC2_2
    392 
    393       // Elixir-style polynomial terms
    394       // XXX currently, Elixir/DVO cannot accept mixed orders
    395       // XXX need to respect the masks
    396       // XXX is wcs->cdelt1,2 always consistent?
    397       int fitOrder = wcs->trans->x->nX;
    398       if (fitOrder > 1) {
    399         for (int i = 0; i <= fitOrder; i++) {
    400           for (int j = 0; j <= fitOrder; j++) {
    401             if (i + j < 2)
    402               continue;
    403             if (i + j > fitOrder)
    404               continue;
    405             sprintf (name, "PCA1X%1dY%1d", i, j);
    406             psMetadataAddF64 (header, PS_LIST_TAIL, name, PS_META_REPLACE, "", wcs->trans->x->coeff[i][j] / pow(cdelt1, i) / pow(cdelt2, j));
    407             sprintf (name, "PCA2X%1dY%1d", i, j);
    408             psMetadataAddF64 (header, PS_LIST_TAIL, name, PS_META_REPLACE, "", wcs->trans->y->coeff[i][j] / pow(cdelt1, i) / pow(cdelt2, j));
    409           }
    410         }
    411         psMetadataAddS32 (header, PS_LIST_TAIL, "NPLYTERM", PS_META_REPLACE, "", fitOrder);
    412       }
    413 
    414       // remove any existing 'CDi_j style' wcs keywords
    415       if (psMetadataLookup(header, "CD1_1")) {
    416         psMetadataRemoveKey(header, "CD1_1");
    417         psMetadataRemoveKey(header, "CD1_2");
    418         psMetadataRemoveKey(header, "CD2_1");
    419         psMetadataRemoveKey(header, "CD2_2");
    420       }
    421 
    422       // Remove 'CDi_jX' WCS keywords
    423       psString cd11 = psStringCopy("CD1_1 ");
    424       psString cd12 = psStringCopy("CD1_2 ");
    425       psString cd21 = psStringCopy("CD2_1 ");
    426       psString cd22 = psStringCopy("CD2_2 ");
    427       for (char extra = 'A'; extra <= 'Z'; extra++) {
    428           cd11[strlen(cd11)-1] = extra;
    429           if (psMetadataLookup(header, cd11)) {
    430               cd12[strlen(cd12)-1] = extra;
    431               cd21[strlen(cd21)-1] = extra;
    432               cd22[strlen(cd22)-1] = extra;
    433               psMetadataRemoveKey(header, cd11);
    434               psMetadataRemoveKey(header, cd12);
    435               psMetadataRemoveKey(header, cd21);
    436               psMetadataRemoveKey(header, cd22);
    437           }
    438       }
    439       psFree(cd11);
    440       psFree(cd12);
    441       psFree(cd21);
    442       psFree(cd22);
     416        double cdelt1 = wcs->cdelt1;
     417        double cdelt2 = wcs->cdelt2;
     418        psMetadataAddF64 (header, PS_LIST_TAIL, "CDELT1", PS_META_REPLACE, "", cdelt1);
     419        psMetadataAddF64 (header, PS_LIST_TAIL, "CDELT2", PS_META_REPLACE, "", cdelt2);
     420
     421        // test the PC00i00j varient:
     422        psMetadataAddF64 (header, PS_LIST_TAIL, "PC001001", PS_META_REPLACE, "", wcs->trans->x->coeff[1][0] / cdelt1); // == PC1_1
     423        psMetadataAddF64 (header, PS_LIST_TAIL, "PC001002", PS_META_REPLACE, "", wcs->trans->x->coeff[0][1] / cdelt2); // == PC1_2
     424        psMetadataAddF64 (header, PS_LIST_TAIL, "PC002001", PS_META_REPLACE, "", wcs->trans->y->coeff[1][0] / cdelt1); // == PC2_1
     425        psMetadataAddF64 (header, PS_LIST_TAIL, "PC002002", PS_META_REPLACE, "", wcs->trans->y->coeff[0][1] / cdelt2); // == PC2_2
     426
     427        // Elixir-style polynomial terms
     428        // XXX currently, Elixir/DVO cannot accept mixed orders
     429        // XXX need to respect the masks
     430        // XXX is wcs->cdelt1,2 always consistent?
     431        int fitOrder = wcs->trans->x->nX;
     432        if (fitOrder > 1) {
     433            for (int i = 0; i <= fitOrder; i++) {
     434                for (int j = 0; j <= fitOrder; j++) {
     435                    if (i + j < 2)
     436                        continue;
     437                    if (i + j > fitOrder)
     438                        continue;
     439                    sprintf (name, "PCA1X%1dY%1d", i, j);
     440                    psMetadataAddF64 (header, PS_LIST_TAIL, name, PS_META_REPLACE, "", wcs->trans->x->coeff[i][j] / pow(cdelt1, i) / pow(cdelt2, j));
     441                    sprintf (name, "PCA2X%1dY%1d", i, j);
     442                    psMetadataAddF64 (header, PS_LIST_TAIL, name, PS_META_REPLACE, "", wcs->trans->y->coeff[i][j] / pow(cdelt1, i) / pow(cdelt2, j));
     443                }
     444            }
     445            psMetadataAddS32 (header, PS_LIST_TAIL, "NPLYTERM", PS_META_REPLACE, "", fitOrder);
     446        }
     447
     448        // remove any existing 'CDi_j style' wcs keywords
     449        if (psMetadataLookup(header, "CD1_1")) {
     450            psMetadataRemoveKey(header, "CD1_1");
     451            psMetadataRemoveKey(header, "CD1_2");
     452            psMetadataRemoveKey(header, "CD2_1");
     453            psMetadataRemoveKey(header, "CD2_2");
     454        }
     455
     456        // Remove 'CDi_jX' WCS keywords
     457        psString cd11 = psStringCopy("CD1_1 ");
     458        psString cd12 = psStringCopy("CD1_2 ");
     459        psString cd21 = psStringCopy("CD2_1 ");
     460        psString cd22 = psStringCopy("CD2_2 ");
     461        for (char extra = 'A'; extra <= 'Z'; extra++) {
     462            cd11[strlen(cd11)-1] = extra;
     463            if (psMetadataLookup(header, cd11)) {
     464                cd12[strlen(cd12)-1] = extra;
     465                cd21[strlen(cd21)-1] = extra;
     466                cd22[strlen(cd22)-1] = extra;
     467                psMetadataRemoveKey(header, cd11);
     468                psMetadataRemoveKey(header, cd12);
     469                psMetadataRemoveKey(header, cd21);
     470                psMetadataRemoveKey(header, cd22);
     471            }
     472        }
     473        psFree(cd11);
     474        psFree(cd12);
     475        psFree(cd21);
     476        psFree(cd22);
    443477
    444478
    445479    } else {
    446480
    447       psMetadataAddF64 (header, PS_LIST_TAIL, "CD1_1", PS_META_REPLACE, "", wcs->trans->x->coeff[1][0]);
    448       psMetadataAddF64 (header, PS_LIST_TAIL, "CD1_2", PS_META_REPLACE, "", wcs->trans->x->coeff[0][1]);
    449       psMetadataAddF64 (header, PS_LIST_TAIL, "CD2_1", PS_META_REPLACE, "", wcs->trans->y->coeff[1][0]);
    450       psMetadataAddF64 (header, PS_LIST_TAIL, "CD2_2", PS_META_REPLACE, "", wcs->trans->y->coeff[0][1]);
    451 
    452       if (psMetadataLookup(header, "PC001001")) {
    453         psMetadataRemoveKey(header, "PC001001");
    454         psMetadataRemoveKey(header, "PC001002");
    455         psMetadataRemoveKey(header, "PC002001");
    456         psMetadataRemoveKey(header, "PC002002");
    457       }
     481        psMetadataAddF64 (header, PS_LIST_TAIL, "CD1_1", PS_META_REPLACE, "", wcs->trans->x->coeff[1][0]);
     482        psMetadataAddF64 (header, PS_LIST_TAIL, "CD1_2", PS_META_REPLACE, "", wcs->trans->x->coeff[0][1]);
     483        psMetadataAddF64 (header, PS_LIST_TAIL, "CD2_1", PS_META_REPLACE, "", wcs->trans->y->coeff[1][0]);
     484        psMetadataAddF64 (header, PS_LIST_TAIL, "CD2_2", PS_META_REPLACE, "", wcs->trans->y->coeff[0][1]);
     485
     486        if (psMetadataLookup(header, "PC001001")) {
     487            psMetadataRemoveKey(header, "PC001001");
     488            psMetadataRemoveKey(header, "PC001002");
     489            psMetadataRemoveKey(header, "PC002001");
     490            psMetadataRemoveKey(header, "PC002002");
     491        }
    458492    }
    459493
     
    473507    // cdelt1,2 has units of degree/pixel
    474508    for (int i = 0; i <= toFPA->x->nX; i++) {
    475         for (int j = 0; j <= toFPA->x->nX; j++) {
    476             toFPA->x->coeff[i][j] *= pixelScale/wcs->cdelt1;
    477             toFPA->y->coeff[i][j] *= pixelScale/wcs->cdelt2;
    478         }
     509        for (int j = 0; j <= toFPA->x->nX; j++) {
     510            toFPA->x->coeff[i][j] *= pixelScale/wcs->cdelt1;
     511            toFPA->y->coeff[i][j] *= pixelScale/wcs->cdelt2;
     512        }
    479513    }
    480514
     
    485519    // projection from TPA (linear microns) to SKY (radians)
    486520    psProjection *toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, PM_RAD_DEG*pdelt1, PM_RAD_DEG*pdelt2, wcs->toSky->type);
     521    toSky->radial = psMemIncrRefCounter (wcs->toSky->radial);
    487522
    488523    if (fpa->toSky == NULL) {
    489524        psFree(fpa->toTPA);
    490525        psFree(fpa->fromTPA);
    491         fpa->toTPA = psPlaneTransformIdentity (1);
    492         fpa->fromTPA = psPlaneTransformIdentity (1);
    493         fpa->toSky = toSky;
     526        fpa->toTPA = psPlaneTransformIdentity (1);
     527        fpa->fromTPA = psPlaneTransformIdentity (1);
     528        fpa->toSky = toSky;
    494529    } else {
    495530
    496         // this section allows the loaded chip to be included in an fpa structure in which
    497         // other chips have already been loaded (ie, the fpa->toTPA, fpa->toSky components have
    498         // already been defined).  we have to adjust to match the existing transformation.
    499 
    500         if (fpa->toTPA == NULL)
    501             psAbort("projection defined, tangent-plane not defined");
    502         if (fpa->fromTPA == NULL)
    503             psAbort("projection defined, tangent-plane not defined");
    504 
    505         // convert from pixels on this chip to pixels on reference chip
    506         // rX has units of refpixels / pixel
    507         double rX = toSky->Xs / fpa->toSky->Xs;
    508         double rY = toSky->Ys / fpa->toSky->Ys;
    509 
    510         for (int i = 0; i <= toFPA->x->nX; i++) {
    511             for (int j = 0; j <= toFPA->x->nY; j++) {
    512                 toFPA->x->coeff[i][j] *= rX;
    513                 toFPA->y->coeff[i][j] *= rY;
    514             }
    515         }
    516 
    517         // apply the exiting fromTPA transformation to make the new toFPA consistent with the toTPA layter
    518         // XXX this only works if toTPA is at most a linear transformation
    519         psPlaneTransform *toFPAnew = psPlaneTransformAlloc(toFPA->x->nX, toFPA->x->nY);
    520         for (int i = 0; i <= toFPA->x->nX; i++) {
    521           for (int j = 0; j <= toFPA->x->nY; j++) {
    522             double f1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[1][0]*toFPA->x->coeff[i][j];
    523             double f2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[0][1]*toFPA->y->coeff[i][j];
    524             toFPAnew->x->coeff[i][j] = f1 + f2;
    525 
    526             double g1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[1][0]*toFPA->x->coeff[i][j];
    527             double g2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[0][1]*toFPA->y->coeff[i][j];
    528             toFPAnew->y->coeff[i][j] = g1 + g2;
    529           }
    530         }
    531         toFPAnew->x->coeff[0][0] += fpa->fromTPA->x->coeff[0][0];
    532         toFPAnew->y->coeff[0][0] += fpa->fromTPA->y->coeff[0][0];
    533 
    534         psFree (toFPA);
    535         toFPA = toFPAnew;
    536 
    537         // adjust reference pixel for new toSky reference coordinate
    538         // find the FPA coordinate of 0,0 for this chip.
    539         psPlane *fpOld = psPlaneAlloc();
    540         psPlane *fpNew = psPlaneAlloc();
    541         psPlane *tp = psPlaneAlloc();
    542         psSphere *sky = psSphereAlloc();
    543 
    544         sky->r = toSky->R;
    545         sky->d = toSky->D;
    546         psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection
    547         psPlaneTransformApply (fpOld, fpa->fromTPA, tp);
    548 
    549         sky->r = fpa->toSky->R;
    550         sky->d = fpa->toSky->D;
    551         psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection
    552         psPlaneTransformApply (fpNew, fpa->fromTPA, tp);
    553 
    554         toFPA->x->coeff[0][0] -= fpNew->x - fpOld->x;
    555         toFPA->y->coeff[0][0] -= fpNew->y - fpOld->y;
    556 
    557         psFree (sky);
    558         psFree (tp);
    559         psFree (fpOld);
    560         psFree (fpNew);
    561 
    562         psFree (toSky);
     531        // this section allows the loaded chip to be included in an fpa structure in which
     532        // other chips have already been loaded (ie, the fpa->toTPA, fpa->toSky components have
     533        // already been defined).  we have to adjust to match the existing transformation.
     534
     535        if (fpa->toTPA == NULL)
     536            psAbort("projection defined, tangent-plane not defined");
     537        if (fpa->fromTPA == NULL)
     538            psAbort("projection defined, tangent-plane not defined");
     539
     540        // convert from pixels on this chip to pixels on reference chip
     541        // rX has units of refpixels / pixel
     542        double rX = toSky->Xs / fpa->toSky->Xs;
     543        double rY = toSky->Ys / fpa->toSky->Ys;
     544
     545        for (int i = 0; i <= toFPA->x->nX; i++) {
     546            for (int j = 0; j <= toFPA->x->nY; j++) {
     547                toFPA->x->coeff[i][j] *= rX;
     548                toFPA->y->coeff[i][j] *= rY;
     549            }
     550        }
     551
     552        // apply the exiting fromTPA transformation to make the new toFPA consistent with the toTPA layter
     553        // XXX this only works if toTPA is at most a linear transformation
     554        psPlaneTransform *toFPAnew = psPlaneTransformAlloc(toFPA->x->nX, toFPA->x->nY);
     555        for (int i = 0; i <= toFPA->x->nX; i++) {
     556            for (int j = 0; j <= toFPA->x->nY; j++) {
     557                double f1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[1][0]*toFPA->x->coeff[i][j];
     558                double f2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[0][1]*toFPA->y->coeff[i][j];
     559                toFPAnew->x->coeff[i][j] = f1 + f2;
     560
     561                double g1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[1][0]*toFPA->x->coeff[i][j];
     562                double g2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[0][1]*toFPA->y->coeff[i][j];
     563                toFPAnew->y->coeff[i][j] = g1 + g2;
     564            }
     565        }
     566        toFPAnew->x->coeff[0][0] += fpa->fromTPA->x->coeff[0][0];
     567        toFPAnew->y->coeff[0][0] += fpa->fromTPA->y->coeff[0][0];
     568
     569        psFree (toFPA);
     570        toFPA = toFPAnew;
     571
     572        // adjust reference pixel for new toSky reference coordinate
     573        // find the FPA coordinate of 0,0 for this chip.
     574        psPlane *fpOld = psPlaneAlloc();
     575        psPlane *fpNew = psPlaneAlloc();
     576        psPlane *tp = psPlaneAlloc();
     577        psSphere *sky = psSphereAlloc();
     578
     579        sky->r = toSky->R;
     580        sky->d = toSky->D;
     581        psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection
     582        psPlaneTransformApply (fpOld, fpa->fromTPA, tp);
     583
     584        sky->r = fpa->toSky->R;
     585        sky->d = fpa->toSky->D;
     586        psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection
     587        psPlaneTransformApply (fpNew, fpa->fromTPA, tp);
     588
     589        toFPA->x->coeff[0][0] -= fpNew->x - fpOld->x;
     590        toFPA->y->coeff[0][0] -= fpNew->y - fpOld->y;
     591
     592        psFree (sky);
     593        psFree (tp);
     594        psFree (fpOld);
     595        psFree (fpNew);
     596
     597        psFree (toSky);
    563598    }
    564599
     
    578613    // XXX if the inversion fails, we probably do not have a valid transform anyway
    579614    if (!chip->fromFPA) {
    580       psWarning ("failed to find a valid transformation");
    581       psFree (chip->toFPA);
    582       return false;
     615        psWarning ("failed to find a valid transformation");
     616        psFree (chip->toFPA);
     617        return false;
    583618    }
    584619
    585620    // this can take a very long time...
    586621    while (fpa->toSky->R < 0)
    587         fpa->toSky->R += 2.0*M_PI;
     622        fpa->toSky->R += 2.0*M_PI;
    588623    while (fpa->toSky->R > 2.0*M_PI)
    589         fpa->toSky->R -= 2.0*M_PI;
     624        fpa->toSky->R -= 2.0*M_PI;
    590625
    591626    fpa->wcsCDkeys = wcs->wcsCDkeys;
    592627
    593628    psTrace ("psastro", 5, "toFPA: %f %f  (%f,%f),(%f,%f)\n",
    594              chip->toFPA->x->coeff[0][0], chip->toFPA->y->coeff[0][0],
    595              chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1],
    596              chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
     629             chip->toFPA->x->coeff[0][0], chip->toFPA->y->coeff[0][0],
     630             chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1],
     631             chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
    597632
    598633    psTrace ("psastro", 5, "frFPA: %f %f  (%f,%f),(%f,%f)\n",
    599              chip->fromFPA->x->coeff[0][0], chip->fromFPA->y->coeff[0][0],
    600              chip->fromFPA->x->coeff[1][0], chip->fromFPA->x->coeff[0][1],
    601              chip->fromFPA->y->coeff[1][0], chip->fromFPA->y->coeff[0][1]);
     634             chip->fromFPA->x->coeff[0][0], chip->fromFPA->y->coeff[0][0],
     635             chip->fromFPA->x->coeff[1][0], chip->fromFPA->x->coeff[0][1],
     636             chip->fromFPA->y->coeff[1][0], chip->fromFPA->y->coeff[0][1]);
    602637
    603638    return true;
     
    613648     */
    614649
    615     // create transformation with 0,0 reference pixel and units of microns/pixel
    616650    psFree (chip->toFPA);
    617     chip->toFPA = psPlaneTransformSetCenter (NULL, wcs->trans, -wcs->crpix1, -wcs->crpix2);
     651    chip->toFPA = psPlaneTransformAlloc(wcs->trans->x->nX, wcs->trans->x->nY);
     652
     653    // copy the toFPA x,y, transformations to the wcs version
     654    chip->toFPA->x = psPolynomial2DCopy (chip->toFPA->x, wcs->trans->x);
     655    chip->toFPA->y = psPolynomial2DCopy (chip->toFPA->y, wcs->trans->y);
     656
     657    // these need to be set based on crval1,2
     658    chip->toFPA->x->coeff[0][0] = wcs->crval1;
     659    chip->toFPA->y->coeff[0][0] = wcs->crval2;
    618660
    619661    // determine the inverse transformation: we need the chip pixels covered by this transform
     
    633675    // cdelt1,2 has units of degrees/micron
    634676    fpa->toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, wcs->cdelt1*PM_RAD_DEG, wcs->cdelt2*PM_RAD_DEG, wcs->toSky->type);
     677    fpa->toSky->radial = psMemIncrRefCounter (wcs->toSky->radial);
    635678
    636679    // create transformation with 0,0 reference pixel
     
    639682    // convert fpa->toTPA to units of unity (microns/micron)
    640683    for (int i = 0; i <= fpa->toTPA->x->nX; i++) {
    641         for (int j = 0; j <= fpa->toTPA->x->nY; j++) {
    642             fpa->toTPA->x->coeff[i][j] /= wcs->cdelt1;
    643             fpa->toTPA->y->coeff[i][j] /= wcs->cdelt2;
    644         }
     684        for (int j = 0; j <= fpa->toTPA->x->nY; j++) {
     685            fpa->toTPA->x->coeff[i][j] /= wcs->cdelt1;
     686            fpa->toTPA->y->coeff[i][j] /= wcs->cdelt2;
     687        }
    645688    }
    646689
     
    648691    // the region defines the FPA pixels covered by the tranformation
    649692    psFree (fpa->fromTPA);
    650     fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, region, 50);
     693    psPlaneTransform *myPT = psPlaneTransformAlloc(fpa->toTPA->x->nX+4, fpa->toTPA->x->nY+4);
     694    fpa->fromTPA = psPlaneTransformInvert(myPT, fpa->toTPA, region, 50);
     695    psFree (myPT);
    651696    return true;
    652697}
     
    684729
    685730    for (int i = 0; i <= toTPA->x->nX; i++) {
    686         for (int j = 0; j <= toTPA->x->nY; j++) {
    687             double f1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[1][0]*chip->toFPA->x->coeff[i][j];
    688             double f2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[0][1]*chip->toFPA->y->coeff[i][j];
    689             toTPA->x->coeff[i][j] = f1 + f2;
    690 
    691             double g1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[1][0]*chip->toFPA->x->coeff[i][j];
    692             double g2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[0][1]*chip->toFPA->y->coeff[i][j];
    693             toTPA->y->coeff[i][j] = g1 + g2;
    694         }
     731        for (int j = 0; j <= toTPA->x->nY; j++) {
     732            double f1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[1][0]*chip->toFPA->x->coeff[i][j];
     733            double f2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[0][1]*chip->toFPA->y->coeff[i][j];
     734            toTPA->x->coeff[i][j] = f1 + f2;
     735
     736            double g1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[1][0]*chip->toFPA->x->coeff[i][j];
     737            double g2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[0][1]*chip->toFPA->y->coeff[i][j];
     738            toTPA->y->coeff[i][j] = g1 + g2;
     739        }
    695740    }
    696741    toTPA->x->coeff[0][0] += fpa->toTPA->x->coeff[0][0];
     
    701746    // convert projection from FPA to SKY into wcs projection (degrees to radians)
    702747    wcs->toSky = psProjectionAlloc (fpa->toSky->R, fpa->toSky->D, PM_RAD_DEG, PM_RAD_DEG, fpa->toSky->type);
     748    wcs->toSky->radial = psMemIncrRefCounter (fpa->toSky->radial);
     749
    703750    wcs->crval1 = fpa->toSky->R*PS_DEG_RAD;
    704751    wcs->crval2 = fpa->toSky->D*PS_DEG_RAD;
     
    714761    psPlane *center = psPlaneTransformGetCenter (tpa1, tol);
    715762    if (!center) {
    716         psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");
    717         psFree (toTPA);
    718         psFree (tpa1);
    719         psFree (wcs);
    720         return NULL;
     763        psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");
     764        psFree (toTPA);
     765        psFree (tpa1);
     766        psFree (wcs);
     767        return NULL;
    721768    }
    722769
     
    751798    // convert wcs->trans to a matrix with units of degrees/pixel
    752799    for (int i = 0; i <= wcs->trans->x->nX; i++) {
    753         for (int j = 0; j <= wcs->trans->x->nY; j++) {
    754             wcs->trans->x->coeff[i][j] *= pdelt1;
    755             wcs->trans->y->coeff[i][j] *= pdelt2;
    756         }
     800        for (int j = 0; j <= wcs->trans->x->nY; j++) {
     801            wcs->trans->x->coeff[i][j] *= pdelt1;
     802            wcs->trans->y->coeff[i][j] *= pdelt2;
     803        }
    757804    }
    758805
     
    773820*/
    774821
    775 // convert the chip-level toFPA to a wcs polynomial transformation
     822// convert the chip-level toFPA to a wcs polynomial transformation.  the pmAstromWCS
     823// structure represents a single layer transformation (e.g., RA-TAN, RA-WRP).  Here we are
     824// converting the chip-level to a WRP projection in the structure.  Later, this will be
     825// converted to the WCS keywords
     826
    776827pmAstromWCS *pmAstromWCSBilevelChipFromFPA (const pmChip *chip, double tol)
    777828{
     
    784835    pmAstromWCS *wcs = pmAstromWCSAlloc(chip->toFPA->x->nX, chip->toFPA->x->nY);
    785836
     837    // copy the toFPA x,y, transformations to the wcs version
     838    wcs->trans->x = psPolynomial2DCopy (wcs->trans->x, chip->toFPA->x);
     839    wcs->trans->y = psPolynomial2DCopy (wcs->trans->y, chip->toFPA->y);
     840
    786841    // Chip to FPA transformation is a Cartesian 'projection'
    787842    // reference pixel for FPA is 0.0, 0.0
    788843    wcs->toSky = psProjectionAlloc (0.0, 0.0, 1.0, 1.0, PS_PROJ_WRP);
    789     wcs->crval1 = 0.0;
    790     wcs->crval2 = 0.0;
    791 
    792     // given transformation, solve for coordinates which yields output coordinates of 0,0
    793     psPlane *center = psPlaneTransformGetCenter (chip->toFPA, tol);
    794     if (!center) {
    795         psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");
    796         psFree (wcs);
    797         return NULL;
    798     }
    799 
    800     // adjust wcs transform to use center as reference coordinate
    801     // resulting transformation has units of microns/pixel
    802     psPlaneTransformSetCenter (wcs->trans, chip->toFPA, center->x, center->y);
    803 
    804     // calculated center is crpix1,2
    805     wcs->crpix1 = center->x;
    806     wcs->crpix2 = center->y;
    807     psFree (center);
    808 
     844
     845    // reference pixel (CRPIX1,2) is (0.0, 0.0):
     846    wcs->crpix1 = 0.0;
     847    wcs->crpix2 = 0.0;
     848
     849    // we need to set CRVAL1,2 for the 0,0 pixel:
     850    wcs->crval1 = psPolynomial2DEval (chip->toFPA->x, 0.0, 0.0);
     851    wcs->crval2 = psPolynomial2DEval (chip->toFPA->y, 0.0, 0.0);
     852
     853    wcs->toSky->R = wcs->crval1*PM_RAD_DEG;
     854    wcs->toSky->D = wcs->crval2*PM_RAD_DEG;
     855
     856    // these need to be set to 0.0 since they have been moved to crpix1,crpix2
     857    wcs->trans->x->coeff[0][0] = 0.0;
     858    wcs->trans->y->coeff[0][0] = 0.0;
     859   
    809860    // output coordinates are in microns : CDELT1,2 has units of microns/pixel
    810861    wcs->cdelt1 = hypot (wcs->trans->x->coeff[1][0], wcs->trans->x->coeff[0][1]);
     
    834885    psPlane *center = psPlaneTransformGetCenter (fpa->toTPA, tol);
    835886    if (!center) {
    836         psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");
    837         psFree (wcs);
    838         return NULL;
     887        psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");
     888        psFree (wcs);
     889        return NULL;
    839890    }
    840891
     
    854905    // convert wcs->trans to units of degree/micron
    855906    for (int i = 0; i <= wcs->trans->x->nX; i++) {
    856         for (int j = 0; j <= wcs->trans->x->nY; j++) {
    857             wcs->trans->x->coeff[i][j] *= pdelt1;
    858             wcs->trans->y->coeff[i][j] *= pdelt2;
    859         }
     907        for (int j = 0; j <= wcs->trans->x->nY; j++) {
     908            wcs->trans->x->coeff[i][j] *= pdelt1;
     909            wcs->trans->y->coeff[i][j] *= pdelt2;
     910        }
    860911    }
    861912
     
    880931    int k=0;
    881932    for (int j=0; j<nSamples; j++) {
    882         double y = bounds->y0 + (j * deltaY / nSamples);
    883         for (int i=0; i<nSamples; i++) {
    884             psPlane *s = psPlaneAlloc();
    885             s->x = bounds->x0 + (i * deltaX / nSamples);
    886             s->y = y;
    887             psArraySet(src, k, s);
    888             psPlane *d = psPlaneTransformApply(NULL, trans, s);
    889             psArraySet(dst, k, d);
    890             psFree(s);  // drop our refs to s and d
    891             psFree(d);
    892             ++k;
    893         }
     933        double y = bounds->y0 + (j * deltaY / nSamples);
     934        for (int i=0; i<nSamples; i++) {
     935            psPlane *s = psPlaneAlloc();
     936            s->x = bounds->x0 + (i * deltaX / nSamples);
     937            s->y = y;
     938            psArraySet(src, k, s);
     939            psPlane *d = psPlaneTransformApply(NULL, trans, s);
     940            psArraySet(dst, k, d);
     941            psFree(s);  // drop our refs to s and d
     942            psFree(d);
     943            ++k;
     944        }
    894945    }
    895946
     
    897948
    898949    if (!psPlaneTransformFit(newTrans, src, dst, 0, 0)) {
    899         psError(PS_ERR_UNKNOWN, false, "linear fit to transform failed");
    900         return NULL;
     950        psError(PS_ERR_UNKNOWN, false, "linear fit to transform failed");
     951        return NULL;
    901952    }
    902953
     
    907958    printf("   i     chip_x  tpa_x     tpa_x_fit     dx         chip_y    tpa_y     tpa_y_fit     dy     dx > 0.5 || dy > 0.5\n");
    908959    for (int i=0; i<psArrayLength(dst); i++) {
    909         psPlane *d = (psPlane *) psArrayGet(dst, i);
    910         psPlane *s = (psPlane *) psArrayGet(src, i);
    911 
    912         new = psPlaneTransformApply(new, newTrans, s);
    913 
    914         double xerr = new->x - d->x;
    915         double yerr = new->y - d->y;
    916         bool bigerr = (fabs(xerr) > .5) || (fabs(yerr) > .5);
    917         printf("%4d %9.2f %9.2f %9.2f %9.4f     %9.2f %9.2f %9.2f %9.4f   %s\n"
    918         , i, s->x, new->x, d->x, xerr, s->y, new->y, d->y, yerr, bigerr ? "BIGERR" : "");
     960        psPlane *d = (psPlane *) psArrayGet(dst, i);
     961        psPlane *s = (psPlane *) psArrayGet(src, i);
     962
     963        new = psPlaneTransformApply(new, newTrans, s);
     964
     965        double xerr = new->x - d->x;
     966        double yerr = new->y - d->y;
     967        bool bigerr = (fabs(xerr) > .5) || (fabs(yerr) > .5);
     968        printf("%4d %9.2f %9.2f %9.2f %9.4f     %9.2f %9.2f %9.2f %9.4f   %s\n"
     969               , i, s->x, new->x, d->x, xerr, s->y, new->y, d->y, yerr, bigerr ? "BIGERR" : "");
    919970    }
    920971    psFree(new);
     
    934985
    935986    if (outFPA == NULL) {
    936         outFPA = inFPA;
     987        outFPA = inFPA;
    937988    }
    938989    if (outChip == NULL) {
    939         outChip = inChip;
     990        outChip = inChip;
    940991    }
    941992    if (outputBounds == NULL) {
    942         outputBounds = pmChipPixels(outChip);
     993        outputBounds = pmChipPixels(outChip);
    943994    }
    944995
     
    946997    psPlaneTransform *chipToTPA = psPlaneTransformCombine(NULL, inChip->toFPA, inFPA->toTPA, *outputBounds, 50);
    947998    if (!chipToTPA) {
    948         psError(PS_ERR_UNKNOWN, false, "failed to create chipToTPA");
    949         return false;
     999        psError(PS_ERR_UNKNOWN, false, "failed to create chipToTPA");
     1000        return false;
    9501001    }
    9511002
     
    9541005    psFree(chipToTPA);
    9551006    if (!chipToFPA) {
    956         psError(PS_ERR_UNKNOWN, false, "linear fit of chip to TPA transform failed");
    957         return false;
     1007        psError(PS_ERR_UNKNOWN, false, "linear fit of chip to TPA transform failed");
     1008        return false;
    9581009    }
    9591010
     
    9611012    psPlaneTransform *outToFPA;
    9621013    if (offset_x != 0. && offset_y != 0.) {
    963         outToFPA = psPlaneTransformSetCenter(NULL, chipToFPA, offset_x, offset_y);
    964         psFree(chipToFPA);
     1014        outToFPA = psPlaneTransformSetCenter(NULL, chipToFPA, offset_x, offset_y);
     1015        psFree(chipToFPA);
    9651016    } else {
    966         outToFPA = chipToFPA;
     1017        outToFPA = chipToFPA;
    9671018    }
    9681019
    9691020    psPlaneTransform *outFromFPA = psPlaneTransformInvert(NULL, outToFPA, *outputBounds, 50);
    9701021    if (!outFromFPA) {
    971         psFree(outToFPA);
    972         psError(PS_ERR_UNKNOWN, false, "inversion of fit of output chip toFPA failed");
    973         return false;
     1022        psFree(outToFPA);
     1023        psError(PS_ERR_UNKNOWN, false, "inversion of fit of output chip toFPA failed");
     1024        return false;
    9741025    }
    9751026
     
    10231074
    10241075    for (int j = 0; j < nSamples; j++) {
    1025         double y = bounds->y0 + (j * deltaY / nSamples);
    1026         for (int i =  0; i < nSamples; i++) {
    1027 
    1028             psSphere srcSky;
    1029             psPlane *srcChip = psPlaneAlloc();
    1030             psPlane *dstTP = psPlaneAlloc();
    1031 
    1032             srcChip->x = bounds->x0 + (i * deltaX / nSamples);
    1033             srcChip->y = y;
    1034 
    1035             psPlaneTransformApply (&srcFP, inChip->toFPA, srcChip);
    1036             psPlaneTransformApply (&srcTP, inFPA->toTPA, &srcFP);
    1037             psDeproject (&srcSky, &srcTP, inFPA->toSky);
    1038 
    1039             // fprintf (stderr, "%f %f | %f %f | %f %f | %f %f\n", srcChip->x, srcChip->y, srcFP.x, srcFP.y, srcTP.x, srcTP.y, srcSky.r*PS_DEG_RAD, srcSky.d*PS_DEG_RAD);
    1040 
    1041             psProject (dstTP, &srcSky, outFPA->toSky);
    1042 
    1043             srcChip->x -= bounds->x0;
    1044             srcChip->y -= bounds->y0;
    1045             psArrayAdd (src, 100, srcChip);
    1046             psArrayAdd (dst, 100, dstTP);
    1047 
    1048             psFree(srcChip);  // drop our refs to s and d
    1049             psFree(dstTP);
    1050         }
     1076        double y = bounds->y0 + (j * deltaY / nSamples);
     1077        for (int i =  0; i < nSamples; i++) {
     1078
     1079            psSphere srcSky;
     1080            psPlane *srcChip = psPlaneAlloc();
     1081            psPlane *dstTP = psPlaneAlloc();
     1082
     1083            srcChip->x = bounds->x0 + (i * deltaX / nSamples);
     1084            srcChip->y = y;
     1085
     1086            psPlaneTransformApply (&srcFP, inChip->toFPA, srcChip);
     1087            psPlaneTransformApply (&srcTP, inFPA->toTPA, &srcFP);
     1088            psDeproject (&srcSky, &srcTP, inFPA->toSky);
     1089
     1090            // fprintf (stderr, "%f %f | %f %f | %f %f | %f %f\n", srcChip->x, srcChip->y, srcFP.x, srcFP.y, srcTP.x, srcTP.y, srcSky.r*PS_DEG_RAD, srcSky.d*PS_DEG_RAD);
     1091
     1092            psProject (dstTP, &srcSky, outFPA->toSky);
     1093
     1094            srcChip->x -= bounds->x0;
     1095            srcChip->y -= bounds->y0;
     1096            psArrayAdd (src, 100, srcChip);
     1097            psArrayAdd (dst, 100, dstTP);
     1098
     1099            psFree(srcChip);  // drop our refs to s and d
     1100            psFree(dstTP);
     1101        }
    10511102    }
    10521103
     
    10561107
    10571108    if (!psPlaneTransformFit(newToFPA, src, dst, 0, 0)) {
    1058         psError(PS_ERR_UNKNOWN, false, "linear fit to transform failed");
    1059         psFree(src);
    1060         psFree(dst);
    1061         return NULL;
     1109        psError(PS_ERR_UNKNOWN, false, "linear fit to transform failed");
     1110        psFree(src);
     1111        psFree(dst);
     1112        return NULL;
    10621113    }
    10631114
     
    10651116    for (int i = 0; i < src->n; i++) {
    10661117
    1067         psSphere srcSky, dstSky;
    1068         psPlane *srcChip = src->data[i];
    1069         psPlane *dstTP   = dst->data[i];
    1070 
    1071         psPlaneTransformApply (&srcFP, newToFPA, srcChip);
    1072         psDeproject (&srcSky, &srcFP, outFPA->toSky);
    1073         psDeproject (&dstSky, dstTP, outFPA->toSky);
    1074 
    1075         double dX = (srcSky.r*PS_DEG_RAD - dstSky.r*PS_DEG_RAD)*3600.0;
    1076         double dY = (srcSky.d*PS_DEG_RAD - dstSky.d*PS_DEG_RAD)*3600.0;
    1077         fprintf (stderr, "%f %f | %f %f | %f %f | %f %f | %f %f | %f %f\n", dX, dY, srcChip->x, srcChip->y, srcFP.x, srcFP.y, dstTP->x, dstTP->y, srcSky.r*PS_DEG_RAD, srcSky.d*PS_DEG_RAD, dstSky.r*PS_DEG_RAD, dstSky.d*PS_DEG_RAD);
     1118        psSphere srcSky, dstSky;
     1119        psPlane *srcChip = src->data[i];
     1120        psPlane *dstTP   = dst->data[i];
     1121
     1122        psPlaneTransformApply (&srcFP, newToFPA, srcChip);
     1123        psDeproject (&srcSky, &srcFP, outFPA->toSky);
     1124        psDeproject (&dstSky, dstTP, outFPA->toSky);
     1125
     1126        double dX = (srcSky.r*PS_DEG_RAD - dstSky.r*PS_DEG_RAD)*3600.0;
     1127        double dY = (srcSky.d*PS_DEG_RAD - dstSky.d*PS_DEG_RAD)*3600.0;
     1128        fprintf (stderr, "%f %f | %f %f | %f %f | %f %f | %f %f | %f %f\n", dX, dY, srcChip->x, srcChip->y, srcFP.x, srcFP.y, dstTP->x, dstTP->y, srcSky.r*PS_DEG_RAD, srcSky.d*PS_DEG_RAD, dstSky.r*PS_DEG_RAD, dstSky.d*PS_DEG_RAD);
    10781129
    10791130    }
     
    10861137    psPlaneTransform *newFromFPA = psPlaneTransformInvert(NULL, newToFPA, *bounds, 1);
    10871138    if (!newFromFPA) {
    1088         psFree(newToFPA);
    1089         psError(PS_ERR_UNKNOWN, false, "inversion of fit of output chip toFPA failed");
    1090         return false;
     1139        psFree(newToFPA);
     1140        psError(PS_ERR_UNKNOWN, false, "inversion of fit of output chip toFPA failed");
     1141        return false;
    10911142    }
    10921143
     
    11111162
    11121163    if (!wcs)
    1113         return;
     1164        return;
    11141165    psFree (wcs->trans);
    11151166    psFree (wcs->toSky);
     
    11331184/*****
    11341185
    1135 For mosaic astrometry, we need to have a starting set of projection terms in which the
    1136 chip-to-FPA terms result in a fixed physical unit on the focal plane (eg, pixels or
    1137 microns).  This set of projections, coupled with an identity toTPA (ie, no distortion) will
    1138 result in substantial errors between the observed and predicted star positions on the focal
    1139 plane: this is the measurement of the optical distortion in the camera.  At the same time,
    1140 we need to carry around the transformations which allow us to make an accurate calculation
    1141 of the position of the stars based on the input (per-chip) astrometry.  These
    1142 transformations will allow us to match the raw and ref stars robustly.  To convert the
    1143 per-chip astrometry (which may have been calculated with a different plate scale for each
    1144 chip) to a collection of astrometry terms for chips in a single mosaic, we need to adjust
    1145 the chip-to-FPA scaling (eg, pc11) to match the variations in the effective plate scale for
    1146 each chip (eg, cdelt1).  Thus, we need to carry around both the
     1186      For mosaic astrometry, we need to have a starting set of projection terms in which the
     1187      chip-to-FPA terms result in a fixed physical unit on the focal plane (eg, pixels or
     1188      microns).  This set of projections, coupled with an identity toTPA (ie, no distortion) will
     1189      result in substantial errors between the observed and predicted star positions on the focal
     1190      plane: this is the measurement of the optical distortion in the camera.  At the same time,
     1191      we need to carry around the transformations which allow us to make an accurate calculation
     1192      of the position of the stars based on the input (per-chip) astrometry.  These
     1193      transformations will allow us to match the raw and ref stars robustly.  To convert the
     1194      per-chip astrometry (which may have been calculated with a different plate scale for each
     1195      chip) to a collection of astrometry terms for chips in a single mosaic, we need to adjust
     1196      the chip-to-FPA scaling (eg, pc11) to match the variations in the effective plate scale for
     1197      each chip (eg, cdelt1).  Thus, we need to carry around both the
    11471198
    11481199*****/
  • trunk/psModules/src/detrend/pmFringeStats.c

    r34085 r39926  
    336336        dfPt[i] = 1.0 / medianSd->sampleStdev;
    337337
    338         psTrace("psModules.detrend", 7, "[%d:%d,%d:%d]: %f %f : %s\n", (int)region.x0, (int)region.x1,
    339                 (int)region.y0, (int)region.y1, fPt[i], dfPt[i], readout->parent->hdu->extname);
     338        if (readout->parent->hdu) {
     339          psTrace("psModules.detrend", 7, "[%d:%d,%d:%d]: %f %f : %s\n", (int)region.x0, (int)region.x1,
     340                  (int)region.y0, (int)region.y1, fPt[i], dfPt[i], readout->parent->hdu->extname);
     341        }
     342        else {
     343          psTrace("psModules.detrend", 7, "[%d:%d,%d:%d]: %f %f : THIS_IS_A_SPOOKY_GHOST_CELL\n", (int)region.x0, (int)region.x1,
     344                  (int)region.y0, (int)region.y1, fPt[i], dfPt[i]);
     345        }
    340346    }
    341347    psFree(sky);
  • trunk/psModules/src/objects/pmPCM_MinimizeChisq.c

    r36859 r39926  
    480480# if (TESTCOPY)
    481481    psImageCopy (pcm->modelConvFlux, pcm->modelFlux, pcm->modelFlux->type.type);
    482 # else
     482# else // TESTCOPY
    483483    if (pcm->use1Dgauss) {
    484484
     
    496496        psImageConvolveKernel (pcm->modelConvFlux, pcm->modelFlux, NULL, 0, pcm->psfFFT);
    497497    }
    498 # endif
     498# endif // TESTCOPY
    499499
    500500    for (int n = 0; n < pcm->dmodelsFlux->n; n++) {
     
    505505# if (TESTCOPY)
    506506        psImageCopy (dmodelConv, dmodel, dmodel->type.type);
    507 # else
     507# else // TESTCOPY
    508508        if (pcm->use1Dgauss) {
    509509            if (USE_1D_CACHE) {
     
    520520            psImageConvolveKernel (dmodelConv, dmodel, NULL, 0, pcm->psfFFT);
    521521        }
    522 # endif
    523     }
    524 # else
     522# endif // TESTCOPY
     523    }
     524# else // PRE_CONVOLVE
    525525    // convolve model image and derivative images with psf via FFT
    526526    psImageConvolveFFT (pcm->modelConvFlux, pcm->modelFlux, NULL, 0, pcm->psf);
     
    547547    }
    548548# endif // PRE-CONVOLVE
    549 # else
     549# else // USE_FFT
    550550    // convolve model image and derivative images with psf direct
    551551    psImageConvolveDirect (pcm->modelConvFlux, pcm->modelFlux, pcm->psf);
  • trunk/psModules/src/objects/pmSourceIO_MatchedRefs.c

    r36856 r39926  
    119119                        psMetadataAdd (row, PS_LIST_TAIL, "RA_REF",     PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r);
    120120                        psMetadataAdd (row, PS_LIST_TAIL, "DEC_REF",    PS_DATA_F64, "declination (deg, J2000)",     PM_DEG_RAD*ref->sky->d);
     121                        psMetadataAdd (row, PS_LIST_TAIL, "RA_RAW",     PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*raw->sky->r);
     122                        psMetadataAdd (row, PS_LIST_TAIL, "DEC_RAW",    PS_DATA_F64, "declination (deg, J2000)",     PM_DEG_RAD*raw->sky->d);
    121123                        psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP_REF", PS_DATA_F32, "x fitted coord on chip",       ref->chip->x);
    122124                        psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP_REF", PS_DATA_F32, "y fitted coord on chip",       ref->chip->y);
  • trunk/psastro/src/psastro.h

    r38040 r39926  
    7070bool              psastroCorrectKH (pmConfig *config, pmFPAview *view, pmReadout *readout, psMetadata *recipe, psArray *inStars);
    7171
    72 psArray          *pmSourceToAstromObj (psArray *sources);
     72psArray          *pmSourceToAstromObj (psArray *sources, float MagOffset);
    7373bool              psastroAstromGuess (int *nStars, pmConfig *config);
    7474bool              psastroAstromGuessCheck (pmConfig *config);
  • trunk/psastro/src/psastroAstromGuess.c

    r31333 r39926  
    7575    pmFPA *fpa = input->fpa;
    7676
    77     if (DEBUG) psastroDumpCorners ("corners.up.guess1.dat", "corners.dn.guess1.dat", fpa);
     77    // this call only works if we have loaded a model : seg fault if not
     78    if (DEBUG && useModel) psastroDumpCorners ("corners.up.guess1.dat", "corners.dn.guess1.dat", fpa);
    7879
    7980    // load mosaic-level astrometry?
     
    9192            if (!psastroAstromGuessSetChip (fpa, chip, view, pixelScale, bilevelAstrometry)) continue;
    9293        }
     94
     95        if (!chip->toFPA || !chip->fromFPA) {
     96          char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     97          fprintf (stderr, "no astrom model for %s, skipping\n", name);
     98          continue;
     99        }
    93100
    94101        if (newFPA) {
     
    312319    while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
    313320        if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; }
     321
     322        if (!chip->toFPA || !chip->fromFPA) {
     323          char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     324          fprintf (stderr, "no astrom model for %s, skipping\n", name);
     325          continue;
     326        }
    314327
    315328        // XXX we are currently inconsistent with marking the good vs the bad data
  • trunk/psastro/src/psastroChipAstrom.c

    r36914 r39926  
    8585                  for (int nn = 0; nn < refstars->n; nn++) {
    8686                    pmAstromObj *ref = refstars->data[nn];
    87                     fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf\n",
     87                    fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf : %f %f\n",
    8888                             ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD,
    8989                             ref->TP->x, ref->TP->y,
    9090                             ref->FP->x, ref->FP->y,
    91                              ref->chip->x, ref->chip->y);
     91                             ref->chip->x, ref->chip->y, ref->Mag, ref->magCal);
    9292                  }
    9393                  fclose (outfile);
     
    101101                  for (int nn = 0; nn < gridrawstars->n; nn++) {
    102102                    pmAstromObj *ref = gridrawstars->data[nn];
    103                     fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf\n",
     103                    fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf : %f %f\n",
    104104                             ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD,
    105105                             ref->TP->x, ref->TP->y,
    106106                             ref->FP->x, ref->FP->y,
    107                              ref->chip->x, ref->chip->y);
     107                             ref->chip->x, ref->chip->y, ref->Mag, ref->magCal);
    108108                  }
    109109                  fclose (outfile);
  • trunk/psastro/src/psastroConvert.c

    r38040 r39926  
    5151    bool status;
    5252
     53    // XXX I want to make this optional
     54    float MagOffset = 0.0;
     55    if (1) {
     56      // select the input data sources
     57      pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
     58      if (!input) {
     59        psError(PSASTRO_ERR_CONFIG, true, "failed to find PSASTRO.INPUT\n");
     60        return false;
     61      }
     62      pmFPA *fpa = input->fpa;
     63
     64      float zeropt, exptime;
     65
     66      // really error-out here?  or just skip?
     67      if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {
     68        psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
     69        zeropt = 0.0;
     70        exptime = 1.0;
     71      }
     72
     73      // recipe values are given in instrumental magnitudes
     74      // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime)
     75      MagOffset = zeropt + 2.5*log10(exptime);
     76    }
     77
    5378    // PSPHOT.SOURCES carries the pmSource objects (from psphot analysis or loaded externally)
    5479    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     
    5984
    6085    // convert the pmSource objects into pmAstromObj objects (drop !STAR and SATSTAR?)
    61     psArray *inStars = pmSourceToAstromObj (sources);
     86    psArray *inStars = pmSourceToAstromObj (sources, MagOffset);
    6287
    6388    // apply Koppenhoefer correction if needed
     
    175200
    176201// select a magnitude range?
    177 psArray *pmSourceToAstromObj (psArray *sources) {
     202psArray *pmSourceToAstromObj (psArray *sources, float MagOffset) {
    178203
    179204    psArray *objects = psArrayAllocEmpty (sources->n);
     
    211236        obj->dMag = source->psfMagErr;
    212237        obj->SBinst = source->psfMag + 5.0*log10(axes.major);
     238        obj->magCal = obj->Mag + MagOffset;
    213239
    214240        // XXX do we have the information giving the readout and cell offset?
  • trunk/psastro/src/psastroDemoDump.c

    r26259 r39926  
    234234        if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; }
    235235
     236        if (!chip->toFPA || !chip->fromFPA) {
     237          char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     238          fprintf (stderr, "no astrom model for %s, skipping\n", name);
     239          continue;
     240        }
     241
    236242        // XXX write out the four corners for a test
    237243        psRegion *region = pmChipPixels (chip);
  • trunk/psastro/src/psastroFixChips.c

    r27639 r39926  
    306306        psRegion *region = pmChipPixels (obsChip);
    307307        obsChip->toFPA   = toFPA;
     308        // NOTE: when we call psPlaneTransformInvert here, we do not increase the order as in other places
    308309        obsChip->fromFPA = psPlaneTransformInvert(NULL, obsChip->toFPA, *region, 50);
    309310        psFree (region);
  • trunk/psastro/src/psastroLoadRefstars.c

    r34967 r39926  
    265265            ref->Color    = 0.0;
    266266        }
     267        ref->magCal   = ref->Mag;
    267268
    268269        // XXX VERY temporary hack to avoid M31 bulge
     
    306307            ref->Color = 0.0;
    307308        }
     309        ref->magCal   = ref->Mag;
    308310
    309311        // XXX VERY temporary hack to avoid M31 bulge
  • trunk/psastro/src/psastroModelAdjust.c

    r21409 r39926  
    2828    }
    2929
     30
     31   
    3032    // if we have not measured the boresite position, no adjustment is needed
    3133    bool fitBoresite = psMetadataLookupBool (&status, recipe, "PSASTRO.MODEL.FIT.BORESITE");
     
    5254        return false;
    5355    }
    54 
     56    float refChipAngleNominal = PS_RAD_DEG*psMetadataLookupF32 (&status, recipe, "PSASTRO.MODEL.REF.CHIP.ANGLE");
     57    if (!refChipName) {
     58        psError(PS_ERR_IO, true, "reference chip is missing from recipe");
     59        return false;
     60    }
     61
     62    int rotatorParity = psMetadataLookupS32(&status, recipe, "PSASTRO.MODEL.ROT.PARITY");
     63    if (!status) psAbort ("Can't find recipe option PSASTRO.MODEL.ROT.PARITY");
     64    psMetadataAddS32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.ROT_PARITY", PS_META_REPLACE, "rotator parity parameter", rotatorParity);
     65   
    5566    // get reference chip from name
    5667    pmChip *refChip = pmConceptsChipFromName (output->fpa, refChipName);
     
    8192        psFree (PT);
    8293    }
    83 
     94   
    8495    // rotate the chip-to-FPA transforms to have 0.0 posangle for refChip;
    8596    // compensate by rotating fpa to TPA transform
    8697
    8798    // get the current posangle of the ref chip
    88     float chipAngle = atan2 (refChip->toFPA->y->coeff[1][0], refChip->toFPA->x->coeff[1][0]);
    89     fprintf (stderr, "chipAngle: %f\n", chipAngle*PS_DEG_RAD);
     99    // this should have a negative sign : chipAngle = -atan2 (dM/dy, dM/dx)
     100    float chipAngle = -atan2 (refChip->toFPA->y->coeff[1][0], refChip->toFPA->x->coeff[1][0]);
     101
     102    // chipAngle should be refChipAngleNominal @ POSANGLE = 0.0
     103    float posAngleOffset = rotatorParity * (chipAngle - refChipAngleNominal);
     104
     105    fprintf (stderr, "chipAngle is: %f, at PA = 0.0, it should be %f, rotating model by %f (parity %d)\n",
     106             chipAngle*PS_DEG_RAD, refChipAngleNominal*PS_DEG_RAD, posAngleOffset*PS_DEG_RAD, rotatorParity);
     107
    90108    // psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POSANGLE", PS_META_REPLACE, "boresite parameter", posangle);
    91109
     
    99117        psRegion *region = pmChipPixels (chip);
    100118
    101         psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, chipAngle);
     119        // this should ALSO have a negative sign: this rotates by +posAngleOffset
     120        psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, posAngleOffset);
    102121        psFree (chip->toFPA);
    103122        chip->toFPA = toFPA;
    104123
    105124        // invert the new fromFPA transform to get the new toFPA transform
     125        // NOTE: when we call psPlaneTransformInvert here, we do not increase the order as in other places
    106126        psPlaneTransform *fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50);
    107127        psFree (chip->fromFPA);
     
    125145
    126146    psFree (output->fpa->fromTPA);
     147    // NOTE: when we call psPlaneTransformInvert here, we do not increase the order as in other places
    127148    output->fpa->fromTPA = psPlaneTransformInvert(NULL, output->fpa->toTPA, *fpaRegion, 50);
    128149
     
    131152
    132153    psMetadata *header = output->fpa->hdu->header;
     154   
    133155    pmAstromWriteBilevelMosaic (header, output->fpa, NONLIN_TOL);
    134156
     
    172194        // invert the new fromFPA transform to get the new toFPA transform
    173195        // the region used here is the region covered by the chip in the FPA
     196        // NOTE: when we call psPlaneTransformInvert here, we do not increase the order as in other places
    174197        psPlaneTransform *fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50);
    175198        psFree (chip->fromFPA);
  • trunk/psastro/src/psastroMosaicAstrom.c

    r27558 r39926  
    1515
    1616bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass);
     17bool psastroProjectionRefit (pmFPA *fpa, psMetadata *recipe);
    1718
    1819// XXX require this fpa to have multiple chip extensions and a PHU?
     
    4344    if (!status) psAbort ("missing config value");
    4445
     46    // if projection is not TAN, fit the measured projection here and combine toTPA/fromTPA functions
     47    bool fitMosaicDistortion = true;
     48    if ((fpa->toSky->type != PS_PROJ_TAN) && (fpa->toSky->type != PS_PROJ_DIS)) {
     49      if (!psastroProjectionRefit (fpa, recipe)) psAbort ("failed to refit distortion");
     50      fitMosaicDistortion = false;
     51    }
     52
    4553    // this should be in a loop with nIter =
    46     for (int iter = 0; iter < nIter; iter++) {
     54    for (int iter = 0; fitMosaicDistortion && (iter < nIter); iter++) {
    4755        if (!psastroMosaicFit (fpa, recipe, outroot, iter)) return false;
    4856    }
    4957
    50     // now fit the chips under the common distortion with higher-order terms
    51     // first, re-perform the match with a slightly tighter circle
    52     if (!psastroMosaicSetMatch (fpa, recipe, nIter)) {
    53         psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (4th pass)");
    54         return false;
    55     }
    56     if (!psastroMosaicChipAstrom (fpa, recipe, nIter)) {
    57         psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (4th pass)");
    58         return false;
    59     }
    60 
    61     if (psTraceGetLevel("psastro.dump") > 0) {
     58    for (int iter = 0; (iter < nIter); iter++) {
     59      // now fit the chips under the common distortion with higher-order terms
     60      // first, re-perform the match with a slightly tighter circle
     61      if (!psastroMosaicSetMatch (fpa, recipe, iter)) {
     62        psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (4th pass %d)", iter);
     63        return false;
     64      }
     65      if (!psastroMosaicChipAstrom (fpa, recipe, iter)) {
     66        psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (pass %d)", iter);
     67        return false;
     68      }
     69     
     70      if (psTraceGetLevel("psastro.dump") > 0) {
    6271        // the last filename (see filenames in psastroMosaicFit)
    6372        char filename[256];
    6473        snprintf (filename, 256, "%s.%d.dat", outroot, 2*nIter + 2);
    6574        psastroDumpMatches (fpa, filename);
    66     }
    67 
     75      }
     76    }
     77   
    6878    // save WCS and analysis metadata in update header.
    6979    // (pull or create local view to entry on readout->analysis)
     
    154164    return true;
    155165}
     166
     167// we have a fpa->toSky projection which is NOT of type TAN along with a toTPA which is
     168// the Identity transform.  we want to convert this to TAN projection plus a non-identity
     169// transformation to take the non-TAN components.
     170
     171// we are going to generate a set of FP->(x,y) using the current projection + fromTPA
     172// transformations along with a set of TP->(x,y) values using the desired TAN projection,
     173// then we will fit TP vs FP
     174
     175bool psastroProjectionRefit (pmFPA *fpa, psMetadata *recipe) {
     176
     177  bool status;
     178
     179    // allocate mosaic-level polynomial transformation and set masks needed by DVO
     180    int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER");
     181    if (!status) {
     182        psError(PSASTRO_ERR_UNKNOWN, false, "failed to find mosaic distortion fit order\n");
     183        return false;
     184    }
     185
     186    pmChip *chip = NULL;
     187    pmCell *cell = NULL;
     188    pmReadout *readout = NULL;
     189    pmFPAview *view = pmFPAviewAlloc (0);
     190
     191    psVector *L = psVectorAllocEmpty (1000, PS_TYPE_F32);
     192    psVector *M = psVectorAllocEmpty (1000, PS_TYPE_F32);
     193
     194    psVector *P = psVectorAllocEmpty (1000, PS_TYPE_F32);
     195    psVector *Q = psVectorAllocEmpty (1000, PS_TYPE_F32);
     196
     197    psProjection *toSkyTan = psProjectionAlloc (fpa->toSky->R, fpa->toSky->D, fpa->toSky->Xs, fpa->toSky->Ys, PS_PROJ_TAN);
     198
     199    float xMin = NAN;
     200    float xMax = NAN;
     201    float yMin = NAN;
     202    float yMax = NAN;
     203
     204    bool firstObject = true;
     205
     206    // this loop selects the matched stars for all chips
     207    while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
     208        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     209        if (!chip->process || !chip->file_exists) continue;
     210       
     211        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
     212            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     213            if (!cell->process || !cell->file_exists) continue;
     214
     215            // process each of the readouts
     216            // XXX there can only be one readout per chip, right?
     217            while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
     218                if (! readout->data_exists) continue;
     219
     220                // select the raw objects for this readout
     221                psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS.SUBSET");
     222                if (refstars == NULL) continue;
     223                psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n);
     224
     225                psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH");
     226                if (matches == NULL) continue;
     227
     228                // we are looking over the matched refstars only to be sure we are
     229                // covering the valid space of the projection + transformation, and not
     230                // beyond
     231
     232                for (int i = 0; i < matches->n; i++) {
     233                    pmAstromMatch *match = matches->data[i];
     234                    pmAstromObj *ref = refstars->data[match->ref];
     235
     236                    psPlane fpOld, tpNew, tpOld;
     237
     238                    psProject (&tpOld, ref->sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection
     239                    psPlaneTransformApply (&fpOld, fpa->fromTPA, &tpOld);
     240
     241                    psProject (&tpNew, ref->sky, toSkyTan); // find the focal-plane coord of this RA,DEC coord using the ref chip projection
     242
     243                    psVectorAppend (L, fpOld.x);
     244                    psVectorAppend (M, fpOld.y);
     245
     246                    psVectorAppend (P, tpNew.x);
     247                    psVectorAppend (Q, tpNew.y);
     248
     249                    if (firstObject) {
     250                      xMin = xMax = fpOld.x;
     251                      yMin = yMax = fpOld.y;
     252                      firstObject = false;
     253                    }
     254
     255                    xMin = PS_MIN (xMin, fpOld.x);
     256                    xMax = PS_MAX (xMax, fpOld.x);
     257                    yMin = PS_MIN (yMin, fpOld.y);
     258                    yMax = PS_MAX (yMax, fpOld.y);
     259                }
     260            }
     261        }
     262    }
     263
     264    // the original transforms are (1, 1), but we will need higher order to fit the distortions
     265    psFree (fpa->toTPA);
     266
     267    // the original transforms are (1, 1), but we will need higher order to fit the distortions
     268    fpa->toTPA = psPlaneTransformAlloc (order, order);
     269    for (int i = 0; i <= fpa->toTPA->x->nX; i++) {
     270        for (int j = 0; j <= fpa->toTPA->x->nY; j++) {
     271            if (i + j > order) {
     272                fpa->toTPA->x->coeffMask[i][j] = PS_POLY_MASK_SET;
     273                fpa->toTPA->y->coeffMask[i][j] = PS_POLY_MASK_SET;
     274            }
     275        }
     276    }
     277
     278    psVectorFitPolynomial2D (fpa->toTPA->x, NULL, 0, P, NULL, L, M);
     279    psVectorFitPolynomial2D (fpa->toTPA->y, NULL, 0, Q, NULL, L, M);
     280   
     281    psRegion fitRegion = psRegionSet (xMin, xMax, yMin, yMax);
     282
     283    // psPlaneTransformInvert will generate a new fromTPA with order to match toTPA
     284    psFree (fpa->fromTPA);
     285    psPlaneTransform *myPT = psPlaneTransformAlloc(fpa->toTPA->x->nX+4, fpa->toTPA->x->nY+4);
     286    fpa->fromTPA = psPlaneTransformInvert (myPT, fpa->toTPA, fitRegion, 100);
     287    psFree (myPT);
     288
     289    psFree (fpa->toSky);
     290    fpa->toSky = toSkyTan;
     291
     292    psFree (L);
     293    psFree (M);
     294    psFree (P);
     295    psFree (Q);
     296
     297    psFree (view);
     298
     299    if (!psastroMosaicSetAstrom (fpa)) {
     300        psError(PSASTRO_ERR_UNKNOWN, false, "failed to apply mosaic distortion terms\n");
     301        return false;
     302    }
     303
     304    return true;
     305}
     306
  • trunk/psastro/src/psastroMosaicCorrectDistortion.c

    r21409 r39926  
    6262
    6363    psFree (fpa->fromTPA);
    64     fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *region, 50);
     64    psPlaneTransform *myPT = psPlaneTransformAlloc(fpa->toTPA->x->nX+4, fpa->toTPA->x->nY+4);
     65    fpa->fromTPA = psPlaneTransformInvert(myPT, fpa->toTPA, *region, 50);
     66    psFree (myPT);
    6567    psFree (region);
    6668
  • trunk/psastro/src/psastroMosaicGradients.c

    r26259 r39926  
    7979    int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER");
    8080    if (!status) {
    81         psError(PSASTRO_ERR_UNKNOWN, false, "failed to find single-chip fit order\n");
     81        psError(PSASTRO_ERR_UNKNOWN, false, "failed to find mosaic distortion fit order\n");
    8282        psFree (gradients);
    8383        psFree (view);
  • trunk/psastro/src/psastroMosaicOneChip.c

    r26259 r39926  
    100100    }
    101101
    102     // XXX allow statitic to be set by the user
     102    // XXX allow statistic to be set by the user
    103103    // only clip if we are fitting the chip parameters.
    104104    psStats *fitStats = NULL;
    105 //    if (order == 0) {
    106 //      fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
    107 //      fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
    108 //      fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
    109 //    } else {
    110         fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
    111         fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
    112         fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
    113 //    }
     105    if (FALSE && (order == 0)) {
     106      fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
     107      fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
     108      fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
     109    } else {
     110      fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
     111      fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
     112      fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
     113    }
    114114
    115115    // need to pass in an update header, sent in from above
    116     pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats);
     116    pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats, recipe);
    117117    if (!results) {
    118118        psError(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n");
  • trunk/psastro/src/psastroOneChipFit.c

    r36914 r39926  
    124124
    125125        // improved fit for astrometric terms
    126         results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats);
     126        results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats, recipe);
    127127        if (!results) {
    128128            psLogMsg ("psastro", 3, "failed to perform the matched fit\n");
  • trunk/psphot/src/psphotSourceStats.c

    r37766 r39926  
    560560        }
    561561
     562        if (psTraceGetLevel("psphot.moments.save")) {
     563          char name[64];
     564          sprintf (name, "moments.v%d.dat", i);
     565          FILE *fout = fopen (name, "w");
     566          for (int j = 0; j < sources->n; j++) {
     567            pmSource *source = sources->data[j];
     568            psAssert (source->moments, "force moments to exist");
     569            source->moments->nPixels = 0;
     570            status = pmSourceMoments (source, 20, sigma[i], 0.0, 0.0, maskVal);
     571            fprintf (fout, "%f %f | %f %f %f | %f\n", source->moments->Mx, source->moments->My, source->moments->Mxx, source->moments->Mxy, source->moments->Myy, source->moments->Sum);
     572          }
     573          fclose (fout);
     574        }
     575
    562576        // choose a grid scale that is a fixed fraction of the psf sigma^2
    563577        float PSF_CLUMP_GRID_SCALE = 0.1*PS_SQR(sigma[i]);
Note: See TracChangeset for help on using the changeset viewer.