head	8.7;
access;
symbols;
locks; strict;
comment	@ * @;


8.7
date	2026.05.11.12.01.10;	author mcalabre;	state Exp;
branches;
next	8.6;

8.6
date	2026.03.29.13.53.56;	author mcalabre;	state Exp;
branches
	8.6.1.1;
next	8.5;

8.5
date	2025.12.06.13.47.41;	author mcalabre;	state Exp;
branches
	8.5.1.1;
next	8.4;

8.4
date	2024.10.28.13.56.17;	author mcalabre;	state Exp;
branches
	8.4.1.1;
next	8.3;

8.3
date	2024.05.13.16.33.00;	author mcalabre;	state Exp;
branches
	8.3.1.1;
next	8.2;

8.2
date	2023.11.16.10.00.30;	author mcalabre;	state Exp;
branches
	8.2.1.1;
next	8.1;

8.1
date	2023.07.05.17.12.07;	author mcalabre;	state Exp;
branches
	8.1.1.1;
next	8.0;

8.0
date	2023.07.01.06.15.05;	author mcalabre;	state Exp;
branches
	8.0.1.1;
next	7.13;

7.13
date	2022.10.07.03.43.35;	author mcalabre;	state Exp;
branches
	7.13.1.1;
next	7.12;

7.12
date	2022.09.09.04.57.58;	author mcalabre;	state Exp;
branches
	7.12.1.1;
next	7.11;

7.11
date	2022.04.26.06.13.52;	author mcalabre;	state Exp;
branches
	7.11.1.1;
next	7.10;

7.10
date	2022.04.23.14.25.15;	author mcalabre;	state Exp;
branches
	7.10.1.1;
next	7.9;

7.9
date	2022.03.25.15.14.49;	author mcalabre;	state Exp;
branches
	7.9.1.1;
next	7.8;

7.8
date	2022.03.25.06.11.49;	author mcalabre;	state Exp;
branches
	7.8.1.1;
next	7.7;

7.7
date	2021.07.12.06.36.49;	author mcalabre;	state Exp;
branches
	7.7.1.1;
next	7.6;

7.6
date	2021.04.13.12.57.01;	author mcalabre;	state Exp;
branches
	7.6.1.1;
next	7.5;

7.5
date	2021.03.20.05.54.58;	author mcalabre;	state Exp;
branches
	7.5.1.1;
next	7.4;

7.4
date	2021.01.31.02.24.52;	author mcalabre;	state Exp;
branches
	7.4.1.1;
next	7.3;

7.3
date	2020.06.03.03.37.03;	author mcalabre;	state Exp;
branches
	7.3.1.1;
next	7.2;

7.2
date	2020.03.09.07.31.23;	author mcalabre;	state Exp;
branches
	7.2.1.1;
next	7.1;

7.1
date	2019.12.31.13.25.19;	author mcalabre;	state Exp;
branches
	7.1.1.1;
next	6.4;

6.4
date	2019.08.15.09.30.18;	author mcalabre;	state Exp;
branches
	6.4.1.1;
next	6.3;

6.3
date	2019.07.12.07.33.39;	author mcalabre;	state Exp;
branches
	6.3.1.1;
next	6.2;

6.2
date	2018.10.20.10.03.14;	author mcalabre;	state Exp;
branches
	6.2.1.1;
next	6.1;

6.1
date	2018.10.19.08.35.17;	author mcalabre;	state Exp;
branches
	6.1.1.1;
next	5.20;

5.20
date	2018.10.05.05.32.41;	author mcalabre;	state Exp;
branches
	5.20.1.1;
next	5.19;

5.19
date	2018.07.26.15.37.05;	author mcalabre;	state Exp;
branches
	5.19.1.1;
next	5.18;

5.18
date	2018.01.10.08.32.14;	author mcalabre;	state Exp;
branches
	5.18.1.1;
next	5.17;

5.17
date	2017.09.18.08.44.24;	author mcalabre;	state Exp;
branches
	5.17.1.1;
next	5.16;

5.16
date	2017.01.15.04.25.02;	author mcalabre;	state Exp;
branches
	5.16.1.1;
next	5.15;

5.15
date	2016.04.05.12.55.11;	author mcalabre;	state Exp;
branches
	5.15.1.1;
next	5.14;

5.14
date	2016.02.07.10.49.32;	author mcalabre;	state Exp;
branches
	5.14.1.1;
next	5.13;

5.13
date	2016.01.26.08.51.15;	author mcalabre;	state Exp;
branches
	5.13.1.1;
next	5.12;

5.12
date	2015.11.15.02.13.01;	author mcalabre;	state Exp;
branches
	5.12.1.1;
next	5.11;

5.11
date	2015.10.18.09.13.06;	author mcalabre;	state Exp;
branches
	5.11.1.1;
next	5.10;

5.10
date	2015.10.09.08.19.16;	author mcalabre;	state Exp;
branches
	5.10.1.1;
next	5.9;

5.9
date	2015.07.21.09.20.03;	author mcalabre;	state Exp;
branches
	5.9.1.1;
next	5.8;

5.8
date	2015.07.08.11.04.01;	author mcalabre;	state Exp;
branches
	5.8.1.1;
next	5.7;

5.7
date	2015.06.29.02.44.17;	author mcalabre;	state Exp;
branches
	5.7.1.1;
next	5.6;

5.6
date	2015.06.14.07.11.25;	author mcalabre;	state Exp;
branches
	5.6.1.1;
next	5.5;

5.5
date	2015.05.05.13.16.32;	author mcalabre;	state Exp;
branches
	5.5.1.1;
next	5.4;

5.4
date	2015.04.21.14.41.06;	author mcalabre;	state Exp;
branches
	5.4.1.1;
next	5.3;

5.3
date	2015.04.21.02.50.52;	author mcalabre;	state Exp;
branches
	5.3.1.1;
next	5.2;

5.2
date	2015.04.15.12.35.08;	author mcalabre;	state Exp;
branches
	5.2.1.1;
next	5.1;

5.1
date	2015.04.07.10.56.38;	author mcalabre;	state Exp;
branches
	5.1.1.1;
next	5.0;

5.0
date	2015.04.05.12.25.01;	author mcalabre;	state Exp;
branches
	5.0.1.1;
next	4.25;

4.25
date	2014.12.14.14.29.37;	author mcalabre;	state Exp;
branches
	4.25.1.1;
next	4.24;

4.24
date	2014.09.18.15.25.01;	author mcalabre;	state Exp;
branches
	4.24.1.1;
next	4.23;

4.23
date	2014.05.13.05.50.52;	author mcalabre;	state Exp;
branches
	4.23.1.1;
next	4.22;

4.22
date	2014.04.12.15.03.53;	author mcalabre;	state Exp;
branches
	4.22.1.1;
next	4.21;

4.21
date	2014.03.24.05.12.28;	author mcalabre;	state Exp;
branches
	4.21.1.1;
next	4.20;

4.20
date	2013.12.18.05.42.50;	author mcalabre;	state Exp;
branches
	4.20.1.1;
next	4.19;

4.19
date	2013.09.29.14.17.52;	author mcalabre;	state Exp;
branches
	4.19.1.1;
next	4.18;

4.18
date	2013.07.13.10.00.05;	author mcalabre;	state Exp;
branches
	4.18.1.1;
next	4.17;

4.17
date	2013.01.29.05.29.21;	author cal103;	state Exp;
branches
	4.17.1.1;
next	4.16;

4.16
date	2012.11.07.04.42.45;	author cal103;	state Exp;
branches
	4.16.1.1;
next	4.15;

4.15
date	2012.09.26.14.26.06;	author cal103;	state Exp;
branches
	4.15.1.1;
next	4.14;

4.14
date	2012.07.13.10.02.32;	author cal103;	state Exp;
branches
	4.14.1.1;
next	4.13;

4.13
date	2012.03.14.07.39.30;	author cal103;	state Exp;
branches
	4.13.1.1;
next	4.12;

4.12
date	2012.02.29.07.57.57;	author cal103;	state Exp;
branches
	4.12.1.1;
next	4.11;

4.11
date	2012.02.20.23.30.02;	author cal103;	state Exp;
branches
	4.11.1.1;
next	4.10;

4.10
date	2012.02.05.23.41.44;	author cal103;	state Exp;
branches
	4.10.1.1;
next	4.9;

4.9
date	2012.01.24.05.40.29;	author cal103;	state Exp;
branches
	4.9.1.1;
next	4.8;

4.8
date	2011.08.15.08.05.54;	author cal103;	state Exp;
branches
	4.8.1.1;
next	4.7;

4.7
date	2011.02.07.07.03.42;	author cal103;	state Exp;
branches
	4.7.1.1;
next	4.6;

4.6
date	2010.11.16.06.15.31;	author cal103;	state Exp;
branches
	4.6.1.1;
next	4.5;

4.5
date	2010.07.16.07.01.26;	author cal103;	state Exp;
branches
	4.5.1.1;
next	4.4;

4.4
date	2009.08.06.07.45.31;	author cal103;	state Exp;
branches
	4.4.1.1;
next	4.3;

4.3
date	2007.12.27.05.35.51;	author cal103;	state Exp;
branches
	4.3.1.1;
next	4.2;

4.2
date	2005.09.22.02.03.02;	author cal103;	state Exp;
branches
	4.2.1.1;
next	4.1;

4.1
date	2005.08.25.06.02.39;	author cal103;	state Exp;
branches;
next	4.0;

4.0
date	2005.02.04.06.26.28;	author cal103;	state Exp;
branches;
next	3.6;

3.6
date	2004.08.25.05.48.55;	author cal103;	state Exp;
branches;
next	3.5;

3.5
date	2004.06.28.01.08.21;	author mcalabre;	state Exp;
branches;
next	3.4;

3.4
date	2004.02.11.00.23.05;	author mcalabre;	state Exp;
branches;
next	3.3;

3.3
date	2003.10.21.08.33.51;	author mcalabre;	state Exp;
branches;
next	3.2;

3.2
date	2003.09.09.04.40.16;	author mcalabre;	state Exp;
branches;
next	3.1;

3.1
date	2003.04.28.04.27.07;	author mcalabre;	state Exp;
branches;
next	3.0;

3.0
date	2003.04.01.04.16.39;	author mcalabre;	state Exp;
branches;
next	2.18;

2.18
date	2002.04.03.01.25.29;	author mcalabre;	state Exp;
branches;
next	2.17;

2.17
date	2001.09.05.05.07.17;	author mcalabre;	state Exp;
branches;
next	2.16;

2.16
date	2001.09.05.04.41.01;	author mcalabre;	state Exp;
branches;
next	2.15;

2.15
date	2000.12.04.08.31.18;	author mcalabre;	state Exp;
branches;
next	2.14;

2.14
date	2000.05.10.04.44.05;	author mcalabre;	state Exp;
branches;
next	2.13;

2.13
date	2000.01.31.07.02.47;	author mcalabre;	state Exp;
branches;
next	2.12;

2.12
date	99.12.13.07.35.38;	author mcalabre;	state Exp;
branches;
next	2.11;

2.11
date	99.12.13.03.41.53;	author mcalabre;	state Exp;
branches;
next	2.10;

2.10
date	99.11.19.01.01.19;	author mcalabre;	state Exp;
branches;
next	2.9;

2.9
date	99.06.16.00.13.37;	author mcalabre;	state Exp;
branches;
next	2.8;

2.8
date	98.02.25.07.05.50;	author mcalabre;	state Exp;
branches;
next	2.7;

2.7
date	98.02.25.06.37.56;	author mcalabre;	state Exp;
branches;
next	2.6;

2.6
date	98.01.30.00.18.21;	author mcalabre;	state Exp;
branches;
next	2.5;

2.5
date	96.05.07.20.32.29;	author mcalabre;	state Exp;
branches;
next	2.4;

2.4
date	95.11.16.06.19.31;	author mcalabre;	state Exp;
branches;
next	2.3;

2.3
date	95.11.16.04.50.43;	author mcalabre;	state Exp;
branches;
next	2.2;

2.2
date	95.11.09.03.23.16;	author mcalabre;	state Exp;
branches;
next	2.1;

2.1
date	95.09.12.07.02.15;	author mcalabre;	state Exp;
branches;
next	;

4.2.1.1
date	2005.12.05.01.39.15;	author cal103;	state Exp;
branches;
next	4.2.1.2;

4.2.1.2
date	2005.12.16.03.48.31;	author cal103;	state Exp;
branches;
next	4.2.1.3;

4.2.1.3
date	2007.06.29.06.44.21;	author cal103;	state Exp;
branches;
next	4.2.1.4;

4.2.1.4
date	2007.08.02.05.58.54;	author cal103;	state Exp;
branches;
next	4.2.1.5;

4.2.1.5
date	2007.12.03.05.12.59;	author cal103;	state Exp;
branches;
next	;

4.3.1.1
date	2007.12.27.13.24.32;	author cal103;	state Exp;
branches;
next	4.3.1.2;

4.3.1.2
date	2009.07.22.06.38.03;	author cal103;	state Exp;
branches;
next	;

4.4.1.1
date	2009.08.10.08.54.26;	author cal103;	state Exp;
branches;
next	4.4.1.2;

4.4.1.2
date	2010.01.19.03.44.00;	author cal103;	state Exp;
branches;
next	;

4.5.1.1
date	2010.07.16.07.05.32;	author cal103;	state Exp;
branches;
next	;

4.6.1.1
date	2010.11.16.06.16.19;	author cal103;	state Exp;
branches;
next	4.6.1.2;

4.6.1.2
date	2011.01.14.06.33.44;	author cal103;	state Exp;
branches;
next	;

4.7.1.1
date	2011.02.07.07.04.23;	author cal103;	state Exp;
branches;
next	;

4.8.1.1
date	2011.08.15.08.07.06;	author cal103;	state Exp;
branches;
next	4.8.1.2;

4.8.1.2
date	2012.01.24.05.23.30;	author cal103;	state Exp;
branches;
next	;

4.9.1.1
date	2012.01.24.05.41.46;	author cal103;	state Exp;
branches;
next	;

4.10.1.1
date	2012.02.05.23.42.47;	author cal103;	state Exp;
branches;
next	;

4.11.1.1
date	2012.02.20.23.31.13;	author cal103;	state Exp;
branches;
next	;

4.12.1.1
date	2012.02.29.07.59.11;	author cal103;	state Exp;
branches;
next	;

4.13.1.1
date	2012.03.14.07.40.38;	author cal103;	state Exp;
branches;
next	4.13.1.2;

4.13.1.2
date	2012.07.13.03.37.00;	author cal103;	state Exp;
branches;
next	;

4.14.1.1
date	2012.07.13.10.04.50;	author cal103;	state Exp;
branches;
next	;

4.15.1.1
date	2012.09.26.14.27.52;	author cal103;	state Exp;
branches;
next	;

4.16.1.1
date	2012.11.07.04.45.57;	author cal103;	state Exp;
branches;
next	4.16.1.2;

4.16.1.2
date	2013.01.29.05.10.40;	author cal103;	state Exp;
branches;
next	;

4.17.1.1
date	2013.01.29.05.32.33;	author cal103;	state Exp;
branches;
next	;

4.18.1.1
date	2013.07.13.10.02.38;	author mcalabre;	state Exp;
branches;
next	;

4.19.1.1
date	2013.09.29.14.20.40;	author mcalabre;	state Exp;
branches;
next	;

4.20.1.1
date	2013.12.18.05.46.56;	author mcalabre;	state Exp;
branches;
next	4.20.1.2;

4.20.1.2
date	2014.03.21.06.26.03;	author mcalabre;	state Exp;
branches;
next	;

4.21.1.1
date	2014.03.24.05.15.29;	author mcalabre;	state Exp;
branches;
next	;

4.22.1.1
date	2014.04.12.15.06.33;	author mcalabre;	state Exp;
branches;
next	;

4.23.1.1
date	2014.05.13.05.53.51;	author mcalabre;	state Exp;
branches;
next	;

4.24.1.1
date	2014.09.18.15.28.11;	author mcalabre;	state Exp;
branches;
next	;

4.25.1.1
date	2014.12.14.14.32.46;	author mcalabre;	state Exp;
branches;
next	4.25.1.2;

4.25.1.2
date	2015.01.06.01.01.52;	author mcalabre;	state Exp;
branches;
next	4.25.1.3;

4.25.1.3
date	2015.03.06.03.41.16;	author mcalabre;	state Exp;
branches;
next	;

5.0.1.1
date	2015.04.05.12.28.02;	author mcalabre;	state Exp;
branches;
next	;

5.1.1.1
date	2015.04.07.11.01.11;	author mcalabre;	state Exp;
branches;
next	;

5.2.1.1
date	2015.04.15.12.39.16;	author mcalabre;	state Exp;
branches;
next	;

5.3.1.1
date	2015.04.21.02.54.03;	author mcalabre;	state Exp;
branches;
next	;

5.4.1.1
date	2015.04.21.14.44.29;	author mcalabre;	state Exp;
branches;
next	;

5.5.1.1
date	2015.05.05.13.21.02;	author mcalabre;	state Exp;
branches;
next	;

5.6.1.1
date	2015.06.14.07.14.46;	author mcalabre;	state Exp;
branches;
next	;

5.7.1.1
date	2015.06.29.02.47.25;	author mcalabre;	state Exp;
branches;
next	;

5.8.1.1
date	2015.07.08.11.07.20;	author mcalabre;	state Exp;
branches;
next	;

5.9.1.1
date	2015.07.21.09.28.10;	author mcalabre;	state Exp;
branches;
next	;

5.10.1.1
date	2015.10.09.08.22.37;	author mcalabre;	state Exp;
branches;
next	;

5.11.1.1
date	2015.10.18.09.16.29;	author mcalabre;	state Exp;
branches;
next	;

5.12.1.1
date	2015.11.15.02.16.16;	author mcalabre;	state Exp;
branches;
next	5.12.1.2;

5.12.1.2
date	2016.01.25.05.17.40;	author mcalabre;	state Exp;
branches;
next	;

5.13.1.1
date	2016.01.26.08.54.34;	author mcalabre;	state Exp;
branches;
next	;

5.14.1.1
date	2016.02.07.10.52.46;	author mcalabre;	state Exp;
branches;
next	;

5.15.1.1
date	2016.04.05.12.58.37;	author mcalabre;	state Exp;
branches;
next	5.15.1.2;

5.15.1.2
date	2017.01.15.04.14.22;	author mcalabre;	state Exp;
branches;
next	;

5.16.1.1
date	2017.01.15.04.29.01;	author mcalabre;	state Exp;
branches;
next	;

5.17.1.1
date	2017.09.18.08.46.00;	author mcalabre;	state Exp;
branches;
next	5.17.1.2;

5.17.1.2
date	2018.01.10.08.26.04;	author mcalabre;	state Exp;
branches;
next	;

5.18.1.1
date	2018.01.10.08.33.04;	author mcalabre;	state Exp;
branches;
next	;

5.19.1.1
date	2018.07.26.15.41.41;	author mcalabre;	state Exp;
branches;
next	;

5.20.1.1
date	2018.10.05.05.33.33;	author mcalabre;	state Exp;
branches;
next	;

6.1.1.1
date	2018.10.19.08.36.15;	author mcalabre;	state Exp;
branches;
next	;

6.2.1.1
date	2018.10.20.10.04.15;	author mcalabre;	state Exp;
branches;
next	6.2.1.2;

6.2.1.2
date	2019.05.10.02.01.28;	author mcalabre;	state Exp;
branches;
next	;

6.3.1.1
date	2019.07.12.07.34.37;	author mcalabre;	state Exp;
branches;
next	;

6.4.1.1
date	2019.08.15.09.31.29;	author mcalabre;	state Exp;
branches;
next	6.4.1.2;

6.4.1.2
date	2019.12.03.06.14.52;	author mcalabre;	state Exp;
branches;
next	6.4.1.3;

6.4.1.3
date	2019.12.31.03.28.29;	author mcalabre;	state Exp;
branches;
next	;

7.1.1.1
date	2019.12.31.13.28.19;	author mcalabre;	state Exp;
branches;
next	;

7.2.1.1
date	2020.03.09.07.34.50;	author mcalabre;	state Exp;
branches;
next	;

7.3.1.1
date	2020.06.03.03.38.11;	author mcalabre;	state Exp;
branches;
next	7.3.1.2;

7.3.1.2
date	2020.08.17.11.20.48;	author mcalabre;	state Exp;
branches;
next	7.3.1.3;

7.3.1.3
date	2021.01.19.14.10.01;	author mcalabre;	state Exp;
branches;
next	7.3.1.4;

7.3.1.4
date	2021.01.28.12.31.20;	author mcalabre;	state Exp;
branches;
next	;

7.4.1.1
date	2021.01.31.02.26.24;	author mcalabre;	state Exp;
branches;
next	;

7.5.1.1
date	2021.03.20.05.56.42;	author mcalabre;	state Exp;
branches;
next	;

7.6.1.1
date	2021.04.13.13.00.36;	author mcalabre;	state Exp;
branches;
next	;

7.7.1.1
date	2021.07.12.06.38.27;	author mcalabre;	state Exp;
branches;
next	7.7.1.2;

7.7.1.2
date	2022.03.25.06.06.00;	author mcalabre;	state Exp;
branches;
next	;

7.8.1.1
date	2022.03.25.06.14.15;	author mcalabre;	state Exp;
branches;
next	;

7.9.1.1
date	2022.03.25.15.16.40;	author mcalabre;	state Exp;
branches;
next	;

7.10.1.1
date	2022.04.23.14.26.54;	author mcalabre;	state Exp;
branches;
next	;

7.11.1.1
date	2022.04.26.06.15.32;	author mcalabre;	state Exp;
branches;
next	;

7.12.1.1
date	2022.09.09.05.00.36;	author mcalabre;	state Exp;
branches;
next	;

7.13.1.1
date	2022.10.07.03.45.47;	author mcalabre;	state Exp;
branches;
next	7.13.1.2;

7.13.1.2
date	2023.06.15.04.17.20;	author mcalabre;	state Exp;
branches;
next	;

8.0.1.1
date	2023.07.01.06.22.44;	author mcalabre;	state Exp;
branches;
next	;

8.1.1.1
date	2023.07.05.17.15.00;	author mcalabre;	state Exp;
branches;
next	;

8.2.1.1
date	2023.11.16.10.05.58;	author mcalabre;	state Exp;
branches;
next	8.2.1.2;

8.2.1.2
date	2024.04.02.14.06.10;	author mcalabre;	state Exp;
branches;
next	;

8.3.1.1
date	2024.05.13.16.35.40;	author mcalabre;	state Exp;
branches;
next	;

8.4.1.1
date	2024.10.28.13.58.41;	author mcalabre;	state Exp;
branches;
next	8.4.1.2;

8.4.1.2
date	2025.12.06.13.37.17;	author mcalabre;	state Exp;
branches;
next	;

8.5.1.1
date	2025.12.06.14.05.16;	author mcalabre;	state Exp;
branches;
next	8.5.1.2;

8.5.1.2
date	2026.03.29.13.36.18;	author mcalabre;	state Exp;
branches;
next	;

8.6.1.1
date	2026.03.29.14.19.27;	author mcalabre;	state Exp;
branches;
next	8.6.1.2;

8.6.1.2
date	2026.04.11.15.55.28;	author mcalabre;	state Exp;
branches;
next	8.6.1.3;

8.6.1.3
date	2026.04.11.15.59.40;	author mcalabre;	state Exp;
branches;
next	8.6.1.4;

8.6.1.4
date	2026.04.25.08.51.08;	author mcalabre;	state Exp;
branches;
next	;


desc
@Program to test wcsmix(), the high level WCSLIB mixed coordinate conversion
routine (requires PGPLOT and X11).
@


8.7
log
@WCSLIB 8.7
@
text
@/*============================================================================
  WCSLIB 8.7 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2026, Mark Calabretta

  This file is part of WCSLIB.

  WCSLIB is free software: you can redistribute it and/or modify it under the
  terms of the GNU Lesser General Public License as published by the Free
  Software Foundation, either version 3 of the License, or (at your option)
  any later version.

  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
  more details.

  You should have received a copy of the GNU Lesser General Public License
  along with WCSLIB.  If not, see http://www.gnu.org/licenses.

  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
  http://www.atnf.csiro.au/computing/software/wcs
  $Id: twcsmix.c,v 8.6.1.4 2026/04/25 08:51:08 mcalabre Exp mcalabre $
*=============================================================================
*
* twcsmix tests wcsmix() for closure on the 1 degree celestial graticule for
* a number of selected projections.  Points with good solutions are marked
* with a white dot on a graphical display of the projection while bad
* solutions are flagged with a red circle.
*
*---------------------------------------------------------------------------*/

// Must be included before anything else.
#include <wcsconfig_tests.h>

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#include <cpgplot.h>

#include <sph.h>
#include <wcs.h>


void mixex(double imin, double imax, double jmin, double jmax);
void id(struct wcsprm *wcs, int *doid, double lng1, double lat1,
        double pixlng, double pixlat);
void grdplt(struct wcsprm *wcs, double imin, double imax, double jmin,
            double jmax);
void parser(struct wcsprm *wcs);

// Set to 1 to skip wcsmix(), primarily for debugging purposes.
const int skip_wcsmix = 0;

// Reporting tolerance for mixex().
const double tol = 1.0e-9;


// In real life these would be encoded as FITS header keyrecords.
const int NAXIS = 4;
const double CRPIX[4] =  {  513.0,  0.0,  0.0,  0.0};
const double PC[4][4] = {{    1.1,  0.0,  0.0,  0.0},
                         {    0.0,  1.0,  0.0,  0.1},
                         {    0.0,  0.0,  1.0,  0.0},
                         {    0.0,  0.2,  0.0,  1.0}};
const double CDELT[4] =  {-9.635265432e-6, 1.0, 1.0, -1.0};

				// The "xxx" is reset in main().
char CTYPE[4][9] = {"WAVE-F2W", "XLAT-xxx", "TIME    ", "XLON-xxx"};

				// Will be reset in mixex().
double CRVAL[4] = {0.214982042, -30.0, -2e3, 150.0};
double LONPOLE  = 150.0;
double LATPOLE  = 999.0;
double RESTFRQ  =   1.42040575e9;
double RESTWAV  =   0.0;

int NPV;
struct pvcard PV[10];		// Projection parameters are set in main().

int main()

{
  printf("Testing WCSLIB wcsmix() routine (twcsmix.c)\n"
         "-------------------------------------------\n");

  // List status return messages.
  printf("\nList of wcs status return values:\n");
  for (int status = 1; status <= 13; status++) {
    printf("%4d: %s.\n", status, wcs_errmsg[status]);
  }


  // PGPLOT initialization.
  char devtyp[16];
  strncpy(devtyp, "/xwindow", 16);
  cpgbeg(0, devtyp, 1, 1);

  // Define pen colours.
  cpgscr(0, 0.00f, 0.00f, 0.00f);
  cpgscr(1, 1.00f, 1.00f, 0.00f);
  cpgscr(2, 1.00f, 1.00f, 1.00f);
  cpgscr(3, 0.50f, 0.50f, 0.80f);
  cpgscr(4, 0.80f, 0.50f, 0.50f);
  cpgscr(5, 0.80f, 0.80f, 0.80f);
  cpgscr(6, 0.50f, 0.50f, 0.80f);
  cpgscr(7, 0.80f, 0.50f, 0.50f);
  cpgscr(8, 0.30f, 0.50f, 0.30f);
  cpgscr(9, 1.00f, 0.75f, 0.00f);


  //------------------------------------------------------------
  // Set the PVi_m keyvalues for the longitude axis so that
  // the fiducial native coordinates are at the native pole,
  // i.e. (phi0,theta0) = (0,90), but without any fiducial
  // offset.  We do this as a test, and also so that all
  // projections will be exercised with the same obliquity
  // parameters.
  //------------------------------------------------------------
  PV[0].i = 4;			// Longitude is on axis 4.
  PV[0].m = 1;			// Parameter number 1.
  PV[0].value =  0.0;		// Fiducial native longitude.

  PV[1].i = 4;			// Longitude is on axis 4.
  PV[1].m = 2;			// Parameter number 2.
  PV[1].value = 90.0;		// Fiducial native latitude.

  // Set the PVi_m keyvalues for the latitude axis.
  PV[2].i = 2;			// Latitude is on axis 2.
  PV[2].m = 1;			// Parameter number 1.
  PV[2].value = 0.0;		// PVi_1 (set below).

  PV[3].i = 2;			// Latitude is on axis 2.
  PV[3].m = 2;			// Parameter number 2.
  PV[3].value = 0.0;		// PVi_2 (set below).

  // ARC: zenithal/azimuthal equidistant.
  memcpy(&CTYPE[1][5], "ARC", 3);
  memcpy(&CTYPE[3][5], "ARC", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  // ZEA: zenithal/azimuthal equal area.
  memcpy(&CTYPE[1][5], "ZEA", 3);
  memcpy(&CTYPE[3][5], "ZEA", 3);
  NPV = 2;
  mixex(-120.0, 120.0, -120.0, 120.0);

  // CYP: cylindrical perspective.
  memcpy(&CTYPE[1][5], "CYP", 3);
  memcpy(&CTYPE[3][5], "CYP", 3);
  NPV = 4;
  PV[2].value = 3.0;
  PV[3].value = 0.8;
  mixex(-170.0, 170.0, -170.0, 170.0);

  // CEA: cylindrical equal area.
  memcpy(&CTYPE[1][5], "CEA", 3);
  memcpy(&CTYPE[3][5], "CEA", 3);
  NPV = 3;
  PV[2].value = 0.75;
  mixex(-200.0, 200.0, -200.0, 200.0);

  // CAR: plate carree.
  memcpy(&CTYPE[1][5], "CAR", 3);
  memcpy(&CTYPE[3][5], "CAR", 3);
  NPV = 2;
  mixex(-210.0, 210.0, -210.0, 210.0);

  // SFL: Sanson-Flamsteed.
  memcpy(&CTYPE[1][5], "SFL", 3);
  memcpy(&CTYPE[3][5], "SFL", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  // PAR: parabolic.
  memcpy(&CTYPE[1][5], "PAR", 3);
  memcpy(&CTYPE[3][5], "PAR", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  // MOL: Mollweide's projection.
  memcpy(&CTYPE[1][5], "MOL", 3);
  memcpy(&CTYPE[3][5], "MOL", 3);
  NPV = 2;
  mixex(-170.0, 170.0, -170.0, 170.0);

  // AIT: Hammer-Aitoff.
  memcpy(&CTYPE[1][5], "AIT", 3);
  memcpy(&CTYPE[3][5], "AIT", 3);
  NPV = 2;
  mixex(-170.0, 170.0, -170.0, 170.0);

  // COE: conic equal area.
  memcpy(&CTYPE[1][5], "COE", 3);
  memcpy(&CTYPE[3][5], "COE", 3);
  NPV = 4;
  PV[2].value = 60.0;
  PV[3].value = 15.0;
  mixex(-140.0, 140.0, -120.0, 160.0);

  // COD: conic equidistant.
  memcpy(&CTYPE[1][5], "COD", 3);
  memcpy(&CTYPE[3][5], "COD", 3);
  NPV = 4;
  PV[2].value = 60.0;
  PV[3].value = 15.0;
  mixex(-200.0, 200.0, -180.0, 220.0);

  // BON: Bonne's projection.
  memcpy(&CTYPE[1][5], "BON", 3);
  memcpy(&CTYPE[3][5], "BON", 3);
  NPV = 3;
  PV[2].value = 30.0;
  mixex(-160.0, 160.0, -160.0, 160.0);

  // PCO: polyconic.
  memcpy(&CTYPE[1][5], "PCO", 3);
  memcpy(&CTYPE[3][5], "PCO", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  // TSC: tangential spherical cube.
  memcpy(&CTYPE[1][5], "TSC", 3);
  memcpy(&CTYPE[3][5], "TSC", 3);
  NPV = 2;
  mixex(-340.0, 80.0, -210.0, 210.0);

  // QSC: quadrilateralized spherical cube.
  memcpy(&CTYPE[1][5], "QSC", 3);
  memcpy(&CTYPE[3][5], "QSC", 3);
  NPV = 2;
  mixex(-340.0, 80.0, -210.0, 210.0);

  cpgend();

  return 0;
}


/*----------------------------------------------------------------------------
*   mixex() tests wcsmix().
*---------------------------------------------------------------------------*/

void mixex(
  double imin,
  double imax,
  double jmin,
  double jmax)

{
  // This routine simulates the actions of a FITS header parser.
  struct wcsprm wcs;
  wcs.flag = -1;
  parser(&wcs);


  // Draw the coordinate graticule.
  grdplt(&wcs, imin, imax, jmin, jmax);
  if (skip_wcsmix) return;


  struct prjprm *wcsprj = &(wcs.cel.prj);
  printf("Testing %s; reporting tolerance %5.1g deg.\n", wcsprj->code, tol);

  // Cache frequently used values.
  int wcslng = wcs.lng;
  int wcslat = wcs.lat;
  double world[4];
  double *worldlng = world + wcslng;
  double *worldlat = world + wcslat;

  world[0] = 0.0;
  world[1] = 0.0;
  world[2] = 0.0;
  world[3] = 0.0;

  world[wcs.spec] = 2.99792458e8 / RESTFRQ;

  for (int lat = 90; lat >= -90; lat--) {
    double lat1 = (double)lat;

    for (int lng = -180; lng <= 180; lng+=15) {
      double lng1 = (double)lng;

      *worldlng = lng1;
      *worldlat = lat1;
      int stat, status;
      double phi, theta, img[4], pix1[4];
      if ((status = wcss2p(&wcs, 1, 4, world, &phi, &theta, img, pix1,
                           &stat))) {
        printf("%3s(s2x): lng1 =%20.15f  lat1 =%20.15f  ERROR %3d\n",
          wcsprj->code, lng1, lat1, status);
        continue;
      }

      double pixlng = pix1[wcslng];
      double pixlat = pix1[wcslat];

      float ipt[1], jpt[1];
      ipt[0] = pixlng;
      jpt[0] = pixlat;
      cpgpt(1, ipt, jpt, -1);

      double lngspan[2], latspan[2];
      lngspan[0] = lng1 - 9.3;
      if (lngspan[0] < -180.0) lngspan[0] = -180.0;
      lngspan[1] = lng1 + 4.1;
      if (lngspan[1] >  180.0) lngspan[1] =  180.0;
      latspan[0] = lat1 - 3.7;
      if (latspan[0] <  -90.0) latspan[0] =  -90.0;
      latspan[1] = lat1 + 7.2;
      if (latspan[1] >   90.0) latspan[1] =   90.0;

      int doid = 1;

      double pix2[4], pix3[4];
      pix2[wcslng] = pixlng;
      if ((status = wcsmix(&wcs, wcslng, 1, latspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  A: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  A: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if (fabs(pix3[wcslng]-pixlng) > tol &&
                (fabs(*worldlat-lat1)  > tol ||
                 fabs(pix2[wcslat]-pixlat) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  A: (lng2) =%20.15f   lat2  =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
      }


      pix2[wcslat] = pixlat;
      if ((status = wcsmix(&wcs, wcslat, 1, latspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  B: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  B: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if (fabs(pix3[wcslat]-pixlat) > tol &&
                (fabs(*worldlat-lat1)  > tol ||
                 fabs(pix2[wcslng]-pixlng) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  B: (lng2) =%20.15f   lat2  =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
      }

      *worldlat = lat1;

      pix2[wcslng] = pixlng;
      if ((status = wcsmix(&wcs, wcslng, 2, lngspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  C: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  C: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if (fabs(pix3[wcslng]-pixlng) > tol &&
                (fabs(*worldlng-lng1)  > tol ||
                 fabs(pix2[wcslat]-pixlat) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  C:  lng2  =%20.15f  (lat2) =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
      }


      pix2[wcslat] = pixlat;
      if ((status = wcsmix(&wcs, wcslat, 2, lngspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  D: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  D: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);

      } else if (fabs(pix3[wcslat]-pixlat) > tol &&
                (fabs(*worldlng-lng1)  > tol ||
                 fabs(pix2[wcslng]-pixlng) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  D:  lng2  =%20.15f  (lat2) =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
      }
    }
  }

  wcsfree(&wcs);

  // Allow 250ms to view the plot on fast machines.
  struct timespec nano = {(time_t)0, 250000000L};
  nanosleep(&nano, 0x0);

  return;
}

//----------------------------------------------------------------------------

void id(
  struct wcsprm *wcs,
  int *doid,
  double lng1,
  double lat1,
  double pixlng,
  double pixlat)

{
  if (*doid) {
    // Compute native coordinates.
    double phi, theta;
    struct celprm *wcscel = &(wcs->cel);
    sphs2x(wcscel->euler, 1, 1, 1, 1, &lng1, &lat1, &phi, &theta);

    struct prjprm *wcsprj = &(wcscel->prj);
    printf("\n%3s:  lng1  =%20.15f   lat1  =%20.15f\n", wcsprj->code, lng1,
      lat1);
    printf(  "       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
    printf(  "        i1  =%20.15f     j1  =%20.15f\n", pixlng, pixlat);
    *doid = 0;

    cpgsci(9);

    float ipt[1], jpt[1];
    ipt[0] = pixlng;
    jpt[0] = pixlat;
    cpgpt(1, ipt, jpt, 21);
    cpgsci(2);
  }

  return;
}

//----------------------------------------------------------------------------

void grdplt(
  struct wcsprm *wcs,
  double imin,
  double imax,
  double jmin,
  double jmax)

{
#define NELEM 9

  // Initialize non-celestial world coordinates.
  double freq = 1.42040595e9 - 180.0 * 62500.0;
  double world[361][NELEM];
  for (int j = 0; j < 361; j++) {
    world[j][0] = 0.0;
    world[j][1] = 0.0;
    world[j][2] = 0.0;
    world[j][3] = 0.0;

    world[j][wcs->spec] = 2.99792458e8 / freq;
    freq += 62500.0;
  }


  // Define PGPLOT viewport.
  float fimax = (float)imax;
  float fimin = (float)imin;
  float fjmax = (float)jmax;
  float fjmin = (float)jmin;
  cpgenv(fimin, fimax, fjmin, fjmax, 1, -2);

  // Draw face boundaries of the quad-cube projections.
  float  ir[1024], jr[1024];
  double img[361][NELEM], pix[361][NELEM];
  struct celprm *wcscel = &(wcs->cel);
  struct prjprm *wcsprj = &(wcscel->prj);
  if (wcsprj->category == QUADCUBE) {
    cpgsci(8);

    // Draw the map boundary.
    for (int j = 0; j < 9; j++) {
      img[j][0] = 0.0;
      img[j][1] = 0.0;
      img[j][2] = 0.0;
      img[j][3] = 0.0;
    }

    img[0][wcs->lng] = -wcsprj->w[0];
    img[0][wcs->lat] =  wcsprj->w[0];
    img[1][wcs->lng] = -wcsprj->w[0];
    img[1][wcs->lat] =  wcsprj->w[0]*3.0;
    img[2][wcs->lng] =  wcsprj->w[0];
    img[2][wcs->lat] =  wcsprj->w[0]*3.0;
    img[3][wcs->lng] =  wcsprj->w[0];
    img[3][wcs->lat] = -wcsprj->w[0]*3.0;
    img[4][wcs->lng] = -wcsprj->w[0];
    img[4][wcs->lat] = -wcsprj->w[0]*3.0;
    img[5][wcs->lng] = -wcsprj->w[0];
    img[5][wcs->lat] =  wcsprj->w[0];
    img[6][wcs->lng] =  wcsprj->w[0]*7.0;
    img[6][wcs->lat] =  wcsprj->w[0];
    img[7][wcs->lng] =  wcsprj->w[0]*7.0;
    img[7][wcs->lat] = -wcsprj->w[0];
    img[8][wcs->lng] = -wcsprj->w[0];
    img[8][wcs->lat] = -wcsprj->w[0];

    linx2p(&(wcs->lin), 9, NELEM, img[0], pix[0]);

    for (int j = 0; j < 9; j++) {
      ir[j] = pix[j][wcs->lng];
      jr[j] = pix[j][wcs->lat];
    }

    cpgline(9, ir, jr);
  }

  double step;
  if (wcsprj->category == POLYCONIC) {
    step = 10.0;
  } else {
    step = 15.0;
  }


  // Draw the native coordinate graticule faintly in the background.
  struct wcsprm native;
  native.flag = -1;
  (void)wcscopy(1, wcs, &native);
  native.crval[wcs->lng] =  0.0;
  native.crval[wcs->lat] = 90.0;
  native.lonpole = 180.0;
  (void)wcsset(&native);

  cpgsci(8);

  // Draw native meridians of longitude.
  int stat[361];
  double phi[361], theta[361];
  struct prjprm *ntvprj = &(native.cel.prj);
  for (int ilng = -180; ilng <= 180; ilng += 15) {
    double lng = (double)ilng;
    if (ilng == -180) lng = -179.99;
    if (ilng ==  180) lng =  179.99;

    double *worldlng = world[0] + native.lng;
    double *worldlat = world[0] + native.lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
      *worldlng = lng;
      *worldlat = (double)ilat;

      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(&native, 181, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    int k = 0;
    double *pixlng = pix[0] + native.lng;
    double *pixlat = pix[0] + native.lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
      if (ntvprj->category == QUADCUBE && k > 0) {
        if (fabs(*pixlng - ir[k-1]) > 2.0 ||
          fabs(*pixlat - jr[k-1]) > 5.0) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }

  // Draw native parallels of latitude.
  for (int ilat = -90; ilat <= 90; ilat += 15) {
    double lat = (double)ilat;

    double *worldlng = world[0] + native.lng;
    double *worldlat = world[0] + native.lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
      double lng = (double)ilng;
      if (ilng == -180) lng = -179.99;
      if (ilng ==  180) lng =  179.99;

      *worldlng = lng;
      *worldlat = lat;

      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(&native, 361, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    int k = 0;
    double *pixlng = pix[0] + native.lng;
    double *pixlat = pix[0] + native.lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
      if (ntvprj->category == QUADCUBE && k > 0) {
        if (fabs(*pixlng - ir[k-1]) > 2.0 ||
          fabs(*pixlat - jr[k-1]) > 5.0) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }

  wcsfree(&native);


  // Draw a colour-coded celestial coordinate graticule.
  int ci = 1;

  // Draw celestial meridians of longitude.
  for (int ilng = -180; ilng <= 180; ilng += 15) {
    double lng = (double)ilng;

    if (++ci > 7) ci = 2;
    cpgsci(ilng?ci:1);

    double *worldlng = world[0] + wcs->lng;
    double *worldlat = world[0] + wcs->lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
      double lat = (double)ilat;

      *worldlng = lng;
      *worldlat = lat;

      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(wcs, 181, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    int k = 0;
    double *pixlng = pix[0] + wcs->lng;
    double *pixlat = pix[0] + wcs->lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
      // Test for discontinuities.
      if (k > 0) {
        if (fabs(*pixlng - ir[k-1]) > step ||
            fabs(*pixlat - jr[k-1]) > step) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }

  // Draw celestial parallels of latitude.
  ci = 1;
  for (int ilat = -90; ilat <= 90; ilat += 15) {
    double lat = (double)ilat;

    if (++ci > 7) ci = 2;
    cpgsci(ilat?ci:1);

    double *worldlng = world[0] + wcs->lng;
    double *worldlat = world[0] + wcs->lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
      double lng = (double)ilng;

      *worldlng = lng;
      *worldlat = lat;

      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(wcs, 361, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    int k = 0;
    double *pixlng = pix[0] + wcs->lng;
    double *pixlat = pix[0] + wcs->lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
      // Test for discontinuities.
      if (k > 0) {
        if (fabs(*pixlng - ir[k-1]) > step ||
            fabs(*pixlat - jr[k-1]) > step) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }


  // Write a descriptive title.
  cpgsci(1);

  char text[80];
  snprintf(text, 80, "%s projection - 15 degree graticule", wcsprj->code);
  printf("\n\n%s\n", text);
  fjmin = jmin - 10.0;
  cpgtext(fimin, fjmin, text);

  snprintf(text, 80, "centered on celestial coordinates (%6.2f,%6.2f)",
    wcscel->ref[0], wcscel->ref[1]);
  printf("%s\n", text);
  fjmin = jmin - 20.0;
  cpgtext(fimin, fjmin, text);

  snprintf(text, 80, "with celestial pole at native coordinates (%7.2f,%7.2f)",
    wcscel->ref[2], wcscel->ref[3]);
  printf("%s\n", text);
  fjmin = jmin - 30.0;
  cpgtext(fimin, fjmin, text);

  cpgsci(2);


  return;
}

//----------------------------------------------------------------------------

void parser(struct wcsprm *wcs)

{
  // In practice a parser would read the FITS header until it encountered
  // the NAXIS keyword which must occur near the start, before any of the
  // WCS keywords.  It would then use wcsini() to allocate memory for
  // arrays in the wcsprm struct and set default values.  In this
  // simulation the header keyvalues are set as global variables.
  wcsini(1, NAXIS, wcs);


  // Now the parser scans the FITS header, identifying WCS keywords and
  // loading their values into the appropriate elements of the wcsprm
  // struct.

  for (int j = 0; j < NAXIS; j++) {
    wcs->crpix[j] = CRPIX[j];
  }

  double *pcij = wcs->pc;
  for (int i = 0; i < NAXIS; i++) {
    for (int j = 0; j < NAXIS; j++) {
      *(pcij++) = PC[i][j];
    }
  }

  for (int i = 0; i < NAXIS; i++) {
    wcs->cdelt[i] = CDELT[i];
  }

  for (int i = 0; i < NAXIS; i++) {
    strncpy(wcs->ctype[i], &CTYPE[i][0], 72);
  }

  for (int i = 0; i < NAXIS; i++) {
    wcs->crval[i] = CRVAL[i];
  }

  wcs->lonpole = LONPOLE;
  wcs->latpole = LATPOLE;

  wcs->restfrq = RESTFRQ;
  wcs->restwav = RESTWAV;

  wcs->npv = NPV;
  for (int i = 0; i < NPV; i++) {
    wcs->pv[i] = PV[i];
  }

  // Extract information from the FITS header.
  int status;
  if ((status = wcsset(wcs))) {
    printf("wcsset ERROR%3d\n", status);
  }

  return;
}
@


8.6
log
@WCSLIB 8.6
@
text
@d2 1
a2 1
  WCSLIB 8.6 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 8.5.1.2 2026/03/29 13:36:18 mcalabre Exp mcalabre $
d32 3
a34 1
#include <cpgplot.h>
d38 3
d46 6
a51 4
void mixex(double, double, double, double);
void id(struct wcsprm *, int *, double, double, double, double);
void grdplt(struct wcsprm *, double, double, double, double);
void parser(struct wcsprm *);
a84 4
  char   text[80];
  register int status;


d90 1
a90 1
  for (status = 1; status <= 13; status++) {
d96 3
a98 2
  strcpy(text, "/xwindow");
  cpgbeg(0, text, 1, 1);
d246 5
a250 3
void mixex(imin, imax, jmin, jmax)

double imax, imin, jmax, jmin;
d253 1
a253 6
  int    doid, lat, lng, wcslat, wcslng, stat, status;
  float  ipt[1], jpt[1];
  double lng1, lat1, phi, theta;
  double latspan[2], lngspan[2];
  double img[4], pix1[4], pix2[4], pix3[4], world[4];
  double pixlng, pixlat, *worldlat, *worldlng;
a254 4
  struct prjprm *wcsprj = &(wcs.cel.prj);


  // This routine simulates the actions of a FITS header parser.
d264 1
d268 5
a272 4
  wcslng = wcs.lng;
  wcslat = wcs.lat;
  worldlng = world + wcslng;
  worldlat = world + wcslat;
d281 2
a282 2
  for (lat = 90; lat >= -90; lat--) {
    lat1 = (double)lat;
d284 2
a285 2
    for (lng = -180; lng <= 180; lng+=15) {
      lng1 = (double)lng;
d289 2
d298 2
a299 2
      pixlng = pix1[wcslng];
      pixlat = pix1[wcslat];
d301 1
d306 1
d316 1
a316 1
      doid = 1;
d318 1
a409 1

d415 4
d424 7
a430 5
void id(wcs, doid, lng1, lat1, pixlng, pixlat)

struct wcsprm *wcs;
int    *doid;
double lng1, lat1, pixlng, pixlat;
a432 5
  float  ipt[1], jpt[1];
  double phi, theta;
  struct celprm *wcscel = &(wcs->cel);
  struct prjprm *wcsprj = &(wcscel->prj);

d435 2
d439 1
d447 2
d460 6
a465 4
void grdplt(wcs, imin, imax, jmin, jmax)

struct wcsprm *wcs;
double imax, imin, jmax, jmin;
a469 12
  char   text[80];
  int    ci, ilat, ilng, j, k, stat[361];
  float  fimax, fimin, fjmax, fjmin, ir[1024], jr[1024];
  double freq, img[361][NELEM], lat, lng, phi[361], pix[361][NELEM], step,
         theta[361], world[361][NELEM];
  double *pixlat, *pixlng, *worldlat, *worldlng;
  struct wcsprm native;
  struct celprm *wcscel = &(wcs->cel);
  struct prjprm *wcsprj = &(wcscel->prj);
  struct prjprm *ntvprj = &(native.cel.prj);


d471 3
a473 2
  freq = 1.42040595e9 - 180.0 * 62500.0;
  for (j = 0; j < 361; j++) {
d485 4
a488 4
  fimax = (float)imax;
  fimin = (float)imin;
  fjmax = (float)jmax;
  fjmin = (float)jmin;
d492 4
d500 1
a500 1
    for (j = 0; j < 9; j++) {
d528 1
a528 1
    for (j = 0; j < 9; j++) {
d536 1
d545 1
d556 5
a560 2
  for (ilng = -180; ilng <= 180; ilng += 15) {
    lng = (double)ilng;
d564 3
a566 3
    worldlng = world[0] + native.lng;
    worldlat = world[0] + native.lat;
    for (ilat = -90; ilat <= 90; ilat++) {
d579 4
a582 4
    k = 0;
    pixlng = pix[0] + native.lng;
    pixlat = pix[0] + native.lat;
    for (ilat = -90; ilat <= 90; ilat++) {
d603 2
a604 2
  for (ilat = -90; ilat <= 90; ilat += 15) {
    lat = (double)ilat;
d606 4
a609 4
    worldlng = world[0] + native.lng;
    worldlat = world[0] + native.lat;
    for (ilng = -180; ilng <= 180; ilng++) {
      lng = (double)ilng;
d625 4
a628 4
    k = 0;
    pixlng = pix[0] + native.lng;
    pixlat = pix[0] + native.lat;
    for (ilng = -180; ilng <= 180; ilng++) {
d652 1
a652 1
  ci = 1;
d655 2
a656 2
  for (ilng = -180; ilng <= 180; ilng += 15) {
    lng = (double)ilng;
d661 4
a664 4
    worldlng = world[0] + wcs->lng;
    worldlat = world[0] + wcs->lat;
    for (ilat = -90; ilat <= 90; ilat++) {
      lat = (double)ilat;
d678 4
a681 4
    k = 0;
    pixlng = pix[0] + wcs->lng;
    pixlat = pix[0] + wcs->lat;
    for (ilat = -90; ilat <= 90; ilat++) {
d704 2
a705 2
  for (ilat = -90; ilat <= 90; ilat += 15) {
    lat = (double)ilat;
d710 4
a713 4
    worldlng = world[0] + wcs->lng;
    worldlat = world[0] + wcs->lat;
    for (ilng = -180; ilng <= 180; ilng++) {
      lng = (double)ilng;
d727 4
a730 4
    k = 0;
    pixlng = pix[0] + wcs->lng;
    pixlat = pix[0] + wcs->lat;
    for (ilng = -180; ilng <= 180; ilng++) {
d754 3
a756 1
  sprintf(text, "%s projection - 15 degree graticule", wcsprj->code);
d761 1
a761 1
  sprintf(text, "centered on celestial coordinates (%6.2f,%6.2f)",
d767 1
a767 1
  sprintf(text, "with celestial pole at native coordinates (%7.2f,%7.2f)",
d781 1
a781 3
void parser(wcs)

struct wcsprm *wcs;
a783 3
  int i, j, status;
  double *pcij;

d796 1
a796 1
  for (j = 0; j < NAXIS; j++) {
d800 3
a802 3
  pcij = wcs->pc;
  for (i = 0; i < NAXIS; i++) {
    for (j = 0; j < NAXIS; j++) {
d807 1
a807 1
  for (i = 0; i < NAXIS; i++) {
d811 2
a812 2
  for (i = 0; i < NAXIS; i++) {
    strcpy(wcs->ctype[i], &CTYPE[i][0]);
d815 1
a815 1
  for (i = 0; i < NAXIS; i++) {
d826 1
a826 1
  for (i = 0; i < NPV; i++) {
d831 1
@


8.6.1.1
log
@WCSLIB 8.6 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.6 2026/03/29 13:53:56 mcalabre Exp $
@


8.6.1.2
log
@Converted to C99-style intermingled variable declarations.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.6.1.1 2026/03/29 14:19:27 mcalabre Exp mcalabre $
d78 4
d87 1
a87 1
  for (int status = 1; status <= 13; status++) {
d93 2
a94 3
  char devtyp[80];
  strcpy(devtyp, "/xwindow");
  cpgbeg(0, devtyp, 1, 1);
d247 10
a257 1
  struct wcsprm wcs;
a266 1
  struct prjprm *wcsprj = &(wcs.cel.prj);
d270 4
a273 5
  int wcslng = wcs.lng;
  int wcslat = wcs.lat;
  double world[4];
  double *worldlng = world + wcslng;
  double *worldlat = world + wcslat;
d282 2
a283 2
  for (int lat = 90; lat >= -90; lat--) {
    double lat1 = (double)lat;
d285 2
a286 2
    for (int lng = -180; lng <= 180; lng+=15) {
      double lng1 = (double)lng;
a289 2
      int stat, status;
      double phi, theta, img[4], pix1[4];
d297 2
a298 2
      double pixlng = pix1[wcslng];
      double pixlat = pix1[wcslat];
a299 1
      float ipt[1], jpt[1];
a303 1
      double lngspan[2], latspan[2];
d313 1
a313 1
      int doid = 1;
a314 1
      double pix2[4], pix3[4];
d424 5
a430 2
    double phi, theta;
    struct celprm *wcscel = &(wcs->cel);
a432 1
    struct prjprm *wcsprj = &(wcscel->prj);
a439 2

    float ipt[1], jpt[1];
d459 12
d472 2
a473 3
  double freq = 1.42040595e9 - 180.0 * 62500.0;
  double world[361][NELEM];
  for (int j = 0; j < 361; j++) {
d485 4
a488 4
  float fimax = (float)imax;
  float fimin = (float)imin;
  float fjmax = (float)jmax;
  float fjmin = (float)jmin;
a491 4
  float  ir[1024], jr[1024];
  double img[361][NELEM], pix[361][NELEM];
  struct celprm *wcscel = &(wcs->cel);
  struct prjprm *wcsprj = &(wcscel->prj);
d496 1
a496 1
    for (int j = 0; j < 9; j++) {
d524 1
a524 1
    for (int j = 0; j < 9; j++) {
a531 1
  double step;
a539 1
  struct wcsprm native;
d550 2
a551 5
  int stat[361];
  double phi[361], theta[361];
  struct prjprm *ntvprj = &(native.cel.prj);
  for (int ilng = -180; ilng <= 180; ilng += 15) {
    double lng = (double)ilng;
d555 3
a557 3
    double *worldlng = world[0] + native.lng;
    double *worldlat = world[0] + native.lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
d570 4
a573 4
    int k = 0;
    double *pixlng = pix[0] + native.lng;
    double *pixlat = pix[0] + native.lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
d594 2
a595 2
  for (int ilat = -90; ilat <= 90; ilat += 15) {
    double lat = (double)ilat;
d597 4
a600 4
    double *worldlng = world[0] + native.lng;
    double *worldlat = world[0] + native.lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
      double lng = (double)ilng;
d616 4
a619 4
    int k = 0;
    double *pixlng = pix[0] + native.lng;
    double *pixlat = pix[0] + native.lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
d643 1
a643 1
  int ci = 1;
d646 2
a647 2
  for (int ilng = -180; ilng <= 180; ilng += 15) {
    double lng = (double)ilng;
d652 4
a655 4
    double *worldlng = world[0] + wcs->lng;
    double *worldlat = world[0] + wcs->lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
      double lat = (double)ilat;
d669 4
a672 4
    int k = 0;
    double *pixlng = pix[0] + wcs->lng;
    double *pixlat = pix[0] + wcs->lat;
    for (int ilat = -90; ilat <= 90; ilat++) {
d695 2
a696 2
  for (int ilat = -90; ilat <= 90; ilat += 15) {
    double lat = (double)ilat;
d701 4
a704 4
    double *worldlng = world[0] + wcs->lng;
    double *worldlat = world[0] + wcs->lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
      double lng = (double)ilng;
d718 4
a721 4
    int k = 0;
    double *pixlng = pix[0] + wcs->lng;
    double *pixlat = pix[0] + wcs->lat;
    for (int ilng = -180; ilng <= 180; ilng++) {
a744 1
  char text[80];
d775 3
d790 1
a790 1
  for (int j = 0; j < NAXIS; j++) {
d794 3
a796 3
  double *pcij = wcs->pc;
  for (int i = 0; i < NAXIS; i++) {
    for (int j = 0; j < NAXIS; j++) {
d801 1
a801 1
  for (int i = 0; i < NAXIS; i++) {
d805 1
a805 1
  for (int i = 0; i < NAXIS; i++) {
d809 1
a809 1
  for (int i = 0; i < NAXIS; i++) {
d820 1
a820 1
  for (int i = 0; i < NPV; i++) {
a824 1
  int status;
@


8.6.1.3
log
@Inconsequential changes prompted by clang-tidy:
 - Replaced use of strcpy() with strncpy(), and sprintf() with snprintf()
   (clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling).
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.6.1.2 2026/04/11 15:55:28 mcalabre Exp mcalabre $
d89 2
a90 2
  char devtyp[16];
  strncpy(devtyp, "/xwindow", 16);
a737 1

d739 1
a739 1
  snprintf(text, 80, "%s projection - 15 degree graticule", wcsprj->code);
d744 1
a744 1
  snprintf(text, 80, "centered on celestial coordinates (%6.2f,%6.2f)",
d750 1
a750 1
  snprintf(text, 80, "with celestial pole at native coordinates (%7.2f,%7.2f)",
d797 1
a797 1
    strncpy(wcs->ctype[i], &CTYPE[i][0], 72);
@


8.6.1.4
log
@Inserted a 250ms pause to slow things down a little during 'make check'.
Converted the K&R-C-style function prototypes to ANSI C.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.6.1.3 2026/04/11 15:59:40 mcalabre Exp mcalabre $
d32 1
a32 3
// Must be included before anything else.
#include <wcsconfig_tests.h>

a35 3
#include <time.h>

#include <cpgplot.h>
d41 4
a44 6
void mixex(double imin, double imax, double jmin, double jmax);
void id(struct wcsprm *wcs, int *doid, double lng1, double lat1,
        double pixlng, double pixlat);
void grdplt(struct wcsprm *wcs, double imin, double imax, double jmin,
            double jmax);
void parser(struct wcsprm *wcs);
d239 3
a241 5
void mixex(
  double imin,
  double imax,
  double jmin,
  double jmax)
d401 1
a406 4
  // Allow 250ms to view the plot on fast machines.
  struct timespec nano = {(time_t)0, 250000000L};
  nanosleep(&nano, 0x0);

d412 5
a416 7
void id(
  struct wcsprm *wcs,
  int *doid,
  double lng1,
  double lat1,
  double pixlng,
  double pixlat)
d446 4
a449 6
void grdplt(
  struct wcsprm *wcs,
  double imin,
  double imax,
  double jmin,
  double jmax)
d765 3
a767 1
void parser(struct wcsprm *wcs)
@


8.5
log
@WCSLIB 8.5
@
text
@d2 2
a3 2
  WCSLIB 8.5 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2025, Mark Calabretta
d21 2
a22 2
  http://www.atnf.csiro.au/people/Mark.Calabretta
  $Id: twcsmix.c,v 8.4.1.2 2025/12/06 13:37:17 mcalabre Exp mcalabre $
@


8.5.1.1
log
@WCSLIB 8.5 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.5 2025/12/06 13:47:41 mcalabre Exp $
@


8.5.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2026, Mark Calabretta
d21 2
a22 2
  http://www.atnf.csiro.au/computing/software/wcs
  $Id: twcsmix.c,v 8.5.1.1 2025/12/06 14:05:16 mcalabre Exp mcalabre $
@


8.4
log
@WCSLIB 8.4
@
text
@d2 2
a3 2
  WCSLIB 8.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2024, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 8.3.1.1 2024/05/13 16:35:40 mcalabre Exp mcalabre $
@


8.4.1.1
log
@WCSLIB 8.4 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.4 2024/10/28 13:56:17 mcalabre Exp $
@


8.4.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2025, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 8.4.1.1 2024/10/28 13:58:41 mcalabre Exp mcalabre $
@


8.3
log
@WCSLIB 8.3
@
text
@d2 1
a2 1
  WCSLIB 8.3 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 8.2.1.2 2024/04/02 14:06:10 mcalabre Exp mcalabre $
@


8.3.1.1
log
@WCSLIB 8.3 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.3 2024/05/13 16:33:00 mcalabre Exp $
@


8.2
log
@WCSLIB 8.2
@
text
@d2 2
a3 2
  WCSLIB 8.2 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2023, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 8.1.1.1 2023/07/05 17:15:00 mcalabre Exp mcalabre $
@


8.2.1.1
log
@WCSLIB 8.2 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.2 2023/11/16 10:00:30 mcalabre Exp $
@


8.2.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2024, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 8.2.1.1 2023/11/16 10:05:58 mcalabre Exp mcalabre $
@


8.1
log
@WCSLIB 8.1
@
text
@d2 1
a2 1
  WCSLIB 8.1 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 8.0.1.1 2023/07/01 06:22:44 mcalabre Exp mcalabre $
@


8.1.1.1
log
@WCSLIB 8.1 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.1 2023/07/05 17:12:07 mcalabre Exp $
@


8.0
log
@WCSLIB 8.0
@
text
@d2 1
a2 1
  WCSLIB 8.0 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.13.1.2 2023/06/15 04:17:20 mcalabre Exp mcalabre $
@


8.0.1.1
log
@WCSLIB 8.0 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 8.0 2023/07/01 06:15:05 mcalabre Exp $
@


7.13
log
@WCSLIB 7.13
@
text
@d2 2
a3 2
  WCSLIB 7.13 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2022, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 7.12.1.1 2022/09/09 05:00:36 mcalabre Exp mcalabre $
@


7.13.1.1
log
@WCSLIB 7.13 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.13 2022/10/07 03:43:35 mcalabre Exp $
@


7.13.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2023, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 7.13.1.1 2022/10/07 03:45:47 mcalabre Exp mcalabre $
@


7.12
log
@WCSLIB 7.12
@
text
@d2 1
a2 1
  WCSLIB 7.12 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.11.1.1 2022/04/26 06:15:32 mcalabre Exp mcalabre $
@


7.12.1.1
log
@WCSLIB 7.12 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.12 2022/09/09 04:57:58 mcalabre Exp $
@


7.11
log
@WCSLIB 7.11
@
text
@d2 1
a2 1
  WCSLIB 7.11 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.10.1.1 2022/04/23 14:26:54 mcalabre Exp mcalabre $
@


7.11.1.1
log
@WCSLIB 7.11 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.11 2022/04/26 06:13:52 mcalabre Exp $
@


7.10
log
@WCSLIB 7.10
@
text
@d2 1
a2 1
  WCSLIB 7.10 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.9.1.1 2022/03/25 15:16:40 mcalabre Exp mcalabre $
@


7.10.1.1
log
@WCSLIB 7.10 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.10 2022/04/23 14:25:15 mcalabre Exp $
@


7.9
log
@WCSLIB 7.9
@
text
@d2 1
a2 1
  WCSLIB 7.9 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.8.1.1 2022/03/25 06:14:15 mcalabre Exp mcalabre $
@


7.9.1.1
log
@WCSLIB 7.9 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.9 2022/03/25 15:14:49 mcalabre Exp $
@


7.8
log
@WCSLIB 7.8
@
text
@d2 1
a2 1
  WCSLIB 7.8 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.7.1.2 2022/03/25 06:06:00 mcalabre Exp mcalabre $
@


7.8.1.1
log
@WCSLIB 7.8 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.8 2022/03/25 06:11:49 mcalabre Exp $
@


7.7
log
@WCSLIB 7.7
@
text
@d2 2
a3 2
  WCSLIB 7.7 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2021, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 7.6.1.1 2021/04/13 13:00:36 mcalabre Exp mcalabre $
@


7.7.1.1
log
@WCSLIB 7.7 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.7 2021/07/12 06:36:49 mcalabre Exp $
@


7.7.1.2
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2022, Mark Calabretta
d22 1
a22 1
  $Id: twcsmix.c,v 7.7.1.1 2021/07/12 06:38:27 mcalabre Exp mcalabre $
@


7.6
log
@WCSLIB 7.6
@
text
@d2 1
a2 1
  WCSLIB 7.6 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.5.1.1 2021/03/20 05:56:42 mcalabre Exp mcalabre $
@


7.6.1.1
log
@WCSLIB 7.6 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.6 2021/04/13 12:57:01 mcalabre Exp $
@


7.5
log
@WCSLIB 7.5
@
text
@d2 1
a2 1
  WCSLIB 7.5 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.4.1.1 2021/01/31 02:26:24 mcalabre Exp mcalabre $
@


7.5.1.1
log
@WCSLIB 7.5 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.5 2021/03/20 05:54:58 mcalabre Exp $
@


7.4
log
@WCSLIB 7.4
@
text
@d2 1
a2 1
  WCSLIB 7.4 - an implementation of the FITS WCS standard.
d22 1
a22 1
  $Id: twcsmix.c,v 7.3.1.4 2021/01/28 12:31:20 mcalabre Exp mcalabre $
@


7.4.1.1
log
@WCSLIB 7.4 development branch.
@
text
@d22 1
a22 1
  $Id: twcsmix.c,v 7.4 2021/01/31 02:24:52 mcalabre Exp $
@


7.3
log
@WCSLIB 7.3
@
text
@d2 2
a3 3

  WCSLIB 7.3 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2020, Mark Calabretta
a19 2
  Direct correspondence concerning WCSLIB to mark@@calabretta.id.au

d22 1
a22 1
  $Id: twcsmix.c,v 7.2.1.1 2020/03/09 07:34:50 mcalabre Exp mcalabre $
d46 1
a46 1
/* Set to 1 to skip wcsmix(), primarily for debugging purposes. */
d49 1
a49 1
/* Reporting tolerance for mixex(). */
d53 1
a53 1
/* In real life these would be encoded as FITS header keyrecords. */
d62 1
a62 1
				/* The "xxx" is reset in main(). */
d65 1
a65 1
				/* Will be reset in mixex(). */
d73 1
a73 1
struct pvcard PV[10];		/* Projection parameters are set in main(). */
d85 1
a85 1
  /* List status return messages. */
d92 1
a92 1
  /* PGPLOT initialization. */
d96 1
a96 1
  /* Define pen colours. */
d109 24
a132 24
  /*----------------------------------------------------------*/
  /* Set the PVi_m keyvalues for the longitude axis so that   */
  /* the fiducial native coordinates are at the native pole,  */
  /* i.e. (phi0,theta0) = (0,90), but without any fiducial    */
  /* offset.  We do this as a test, and also so that all      */
  /* projections will be exercised with the same obliquity    */
  /* parameters.                                              */
  /*----------------------------------------------------------*/
  PV[0].i = 4;			/* Longitude is on axis 4.     */
  PV[0].m = 1;			/* Parameter number 1.         */
  PV[0].value =  0.0;		/* Fiducial native longitude.  */

  PV[1].i = 4;			/* Longitude is on axis 4.     */
  PV[1].m = 2;			/* Parameter number 2.         */
  PV[1].value = 90.0;		/* Fiducial native latitude.   */

  /* Set the PVi_m keyvalues for the latitude axis.           */
  PV[2].i = 2;			/* Latitude is on axis 2.      */
  PV[2].m = 1;			/* Parameter number 1.         */
  PV[2].value = 0.0;		/* PVi_1 (set below).          */

  PV[3].i = 2;			/* Latitude is on axis 2.      */
  PV[3].m = 2;			/* Parameter number 2.         */
  PV[3].value = 0.0;		/* PVi_2 (set below).          */
d134 1
a134 1
  /* ARC: zenithal/azimuthal equidistant. */
d140 1
a140 1
  /* ZEA: zenithal/azimuthal equal area. */
d146 1
a146 1
  /* CYP: cylindrical perspective. */
d154 1
a154 1
  /* CEA: cylindrical equal area. */
d161 1
a161 1
  /* CAR: plate carree. */
d167 1
a167 1
  /* SFL: Sanson-Flamsteed. */
d173 1
a173 1
  /* PAR: parabolic. */
d179 1
a179 1
  /* MOL: Mollweide's projection. */
d185 1
a185 1
  /* AIT: Hammer-Aitoff. */
d191 1
a191 1
  /* COE: conic equal area. */
d199 1
a199 1
  /* COD: conic equidistant. */
d207 1
a207 1
  /* BON: Bonne's projection. */
d214 1
a214 1
  /* PCO: polyconic. */
d220 1
a220 1
  /* TSC: tangential spherical cube. */
d226 1
a226 1
  /* QSC: quadrilateralized spherical cube. */
d257 1
a257 1
  /* This routine simulates the actions of a FITS header parser. */
d262 1
a262 1
  /* Draw the coordinate graticule. */
d269 1
a269 1
  /* Cache frequently used values. */
d415 1
a415 1
/*--------------------------------------------------------------------------*/
d430 1
a430 1
    /* Compute native coordinates. */
d449 1
a449 1
/*--------------------------------------------------------------------------*/
d471 1
a471 1
  /* Initialize non-celestial world coordinates. */
d484 1
a484 1
  /* Define PGPLOT viewport. */
d491 1
a491 1
  /* Draw face boundaries of the quad-cube projections. */
d495 1
a495 1
    /* Draw the map boundary. */
d539 1
a539 1
  /* Draw the native coordinate graticule faintly in the background. */
d549 1
a549 1
  /* Draw native meridians of longitude. */
d593 1
a593 1
  /* Draw native parallels of latitude. */
d642 1
a642 1
  /* Draw a colour-coded celestial coordinate graticule. */
d645 1
a645 1
  /* Draw celestial meridians of longitude. */
d673 1
a673 1
      /* Test for discontinuities. */
d693 1
a693 1
  /* Draw celestial parallels of latitude. */
d722 1
a722 1
      /* Test for discontinuities. */
d743 1
a743 1
  /* Write a descriptive title. */
d768 1
a768 1
/*--------------------------------------------------------------------------*/
d778 5
a782 5
  /* In practice a parser would read the FITS header until it encountered  */
  /* the NAXIS keyword which must occur near the start, before any of the  */
  /* WCS keywords.  It would then use wcsini() to allocate memory for      */
  /* arrays in the wcsprm struct and set default values.  In this          */
  /* simulation the header keyvalues are set as global variables.          */
d786 3
a788 3
  /* Now the parser scans the FITS header, identifying WCS keywords and    */
  /* loading their values into the appropriate elements of the wcsprm      */
  /* struct.                                                               */
d824 1
a824 1
  /* Extract information from the FITS header. */
@


7.3.1.1
log
@WCSLIB 7.3 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 7.3 2020/06/03 03:37:03 mcalabre Exp $
@


7.3.1.2
log
@Switched to C99 style commenting (i.e. using //) within the code.
@
text
@d2 1
d25 1
a25 1
  $Id: twcsmix.c,v 7.3.1.1 2020/06/03 03:38:11 mcalabre Exp mcalabre $
d49 1
a49 1
// Set to 1 to skip wcsmix(), primarily for debugging purposes.
d52 1
a52 1
// Reporting tolerance for mixex().
d56 1
a56 1
// In real life these would be encoded as FITS header keyrecords.
d65 1
a65 1
				// The "xxx" is reset in main().
d68 1
a68 1
				// Will be reset in mixex().
d76 1
a76 1
struct pvcard PV[10];		// Projection parameters are set in main().
d88 1
a88 1
  // List status return messages.
d95 1
a95 1
  // PGPLOT initialization.
d99 1
a99 1
  // Define pen colours.
d112 24
a135 24
  //------------------------------------------------------------
  // Set the PVi_m keyvalues for the longitude axis so that
  // the fiducial native coordinates are at the native pole,
  // i.e. (phi0,theta0) = (0,90), but without any fiducial
  // offset.  We do this as a test, and also so that all
  // projections will be exercised with the same obliquity
  // parameters.
  //------------------------------------------------------------
  PV[0].i = 4;			// Longitude is on axis 4.
  PV[0].m = 1;			// Parameter number 1.
  PV[0].value =  0.0;		// Fiducial native longitude.

  PV[1].i = 4;			// Longitude is on axis 4.
  PV[1].m = 2;			// Parameter number 2.
  PV[1].value = 90.0;		// Fiducial native latitude.

  // Set the PVi_m keyvalues for the latitude axis.
  PV[2].i = 2;			// Latitude is on axis 2.
  PV[2].m = 1;			// Parameter number 1.
  PV[2].value = 0.0;		// PVi_1 (set below).

  PV[3].i = 2;			// Latitude is on axis 2.
  PV[3].m = 2;			// Parameter number 2.
  PV[3].value = 0.0;		// PVi_2 (set below).
d137 1
a137 1
  // ARC: zenithal/azimuthal equidistant.
d143 1
a143 1
  // ZEA: zenithal/azimuthal equal area.
d149 1
a149 1
  // CYP: cylindrical perspective.
d157 1
a157 1
  // CEA: cylindrical equal area.
d164 1
a164 1
  // CAR: plate carree.
d170 1
a170 1
  // SFL: Sanson-Flamsteed.
d176 1
a176 1
  // PAR: parabolic.
d182 1
a182 1
  // MOL: Mollweide's projection.
d188 1
a188 1
  // AIT: Hammer-Aitoff.
d194 1
a194 1
  // COE: conic equal area.
d202 1
a202 1
  // COD: conic equidistant.
d210 1
a210 1
  // BON: Bonne's projection.
d217 1
a217 1
  // PCO: polyconic.
d223 1
a223 1
  // TSC: tangential spherical cube.
d229 1
a229 1
  // QSC: quadrilateralized spherical cube.
d260 1
a260 1
  // This routine simulates the actions of a FITS header parser.
d265 1
a265 1
  // Draw the coordinate graticule.
d272 1
a272 1
  // Cache frequently used values.
d418 1
a418 1
//----------------------------------------------------------------------------
d433 1
a433 1
    // Compute native coordinates.
d452 1
a452 1
//----------------------------------------------------------------------------
d474 1
a474 1
  // Initialize non-celestial world coordinates.
d487 1
a487 1
  // Define PGPLOT viewport.
d494 1
a494 1
  // Draw face boundaries of the quad-cube projections.
d498 1
a498 1
    // Draw the map boundary.
d542 1
a542 1
  // Draw the native coordinate graticule faintly in the background.
d552 1
a552 1
  // Draw native meridians of longitude.
d596 1
a596 1
  // Draw native parallels of latitude.
d645 1
a645 1
  // Draw a colour-coded celestial coordinate graticule.
d648 1
a648 1
  // Draw celestial meridians of longitude.
d676 1
a676 1
      // Test for discontinuities.
d696 1
a696 1
  // Draw celestial parallels of latitude.
d725 1
a725 1
      // Test for discontinuities.
d746 1
a746 1
  // Write a descriptive title.
d771 1
a771 1
//----------------------------------------------------------------------------
d781 5
a785 5
  // In practice a parser would read the FITS header until it encountered
  // the NAXIS keyword which must occur near the start, before any of the
  // WCS keywords.  It would then use wcsini() to allocate memory for
  // arrays in the wcsprm struct and set default values.  In this
  // simulation the header keyvalues are set as global variables.
d789 3
a791 3
  // Now the parser scans the FITS header, identifying WCS keywords and
  // loading their values into the appropriate elements of the wcsprm
  // struct.
d827 1
a827 1
  // Extract information from the FITS header.
@


7.3.1.3
log
@Updated date in copyright notice.
@
text
@d3 1
a3 1
  Copyright (C) 1995-2021, Mark Calabretta
d24 1
a24 1
  $Id: twcsmix.c,v 7.3.1.2 2020/08/17 11:20:48 mcalabre Exp mcalabre $
@


7.3.1.4
log
@Removed my email address from the copyright notice.
@
text
@d20 2
d24 1
a24 1
  $Id: twcsmix.c,v 7.3.1.3 2021/01/19 14:10:01 mcalabre Exp mcalabre $
@


7.2
log
@WCSLIB 7.2
@
text
@d3 1
a3 1
  WCSLIB 7.2 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 7.1.1.1 2019/12/31 13:28:19 mcalabre Exp mcalabre $
@


7.2.1.1
log
@WCSLIB 7.2 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 7.2 2020/03/09 07:31:23 mcalabre Exp $
@


7.1
log
@WCSLIB 7.1
@
text
@d3 1
a3 1
  WCSLIB 7.1 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 6.4.1.3 2019/12/31 03:28:29 mcalabre Exp mcalabre $
@


7.1.1.1
log
@WCSLIB 7.1 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 7.1 2019/12/31 13:25:19 mcalabre Exp $
@


6.4
log
@WCSLIB 6.4
@
text
@d3 2
a4 2
  WCSLIB 6.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2019, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 6.3.1.1 2019/07/12 07:34:37 mcalabre Exp mcalabre $
d138 2
a139 2
  strncpy(&CTYPE[1][5], "ARC", 3);
  strncpy(&CTYPE[3][5], "ARC", 3);
d144 2
a145 2
  strncpy(&CTYPE[1][5], "ZEA", 3);
  strncpy(&CTYPE[3][5], "ZEA", 3);
d150 2
a151 2
  strncpy(&CTYPE[1][5], "CYP", 3);
  strncpy(&CTYPE[3][5], "CYP", 3);
d158 2
a159 2
  strncpy(&CTYPE[1][5], "CEA", 3);
  strncpy(&CTYPE[3][5], "CEA", 3);
d165 2
a166 2
  strncpy(&CTYPE[1][5], "CAR", 3);
  strncpy(&CTYPE[3][5], "CAR", 3);
d171 2
a172 2
  strncpy(&CTYPE[1][5], "SFL", 3);
  strncpy(&CTYPE[3][5], "SFL", 3);
d177 2
a178 2
  strncpy(&CTYPE[1][5], "PAR", 3);
  strncpy(&CTYPE[3][5], "PAR", 3);
d183 2
a184 2
  strncpy(&CTYPE[1][5], "MOL", 3);
  strncpy(&CTYPE[3][5], "MOL", 3);
d189 2
a190 2
  strncpy(&CTYPE[1][5], "AIT", 3);
  strncpy(&CTYPE[3][5], "AIT", 3);
d195 2
a196 2
  strncpy(&CTYPE[1][5], "COE", 3);
  strncpy(&CTYPE[3][5], "COE", 3);
d203 2
a204 2
  strncpy(&CTYPE[1][5], "COD", 3);
  strncpy(&CTYPE[3][5], "COD", 3);
d211 2
a212 2
  strncpy(&CTYPE[1][5], "BON", 3);
  strncpy(&CTYPE[3][5], "BON", 3);
d218 2
a219 2
  strncpy(&CTYPE[1][5], "PCO", 3);
  strncpy(&CTYPE[3][5], "PCO", 3);
d224 2
a225 2
  strncpy(&CTYPE[1][5], "TSC", 3);
  strncpy(&CTYPE[3][5], "TSC", 3);
d230 2
a231 2
  strncpy(&CTYPE[1][5], "QSC", 3);
  strncpy(&CTYPE[3][5], "QSC", 3);
@


6.4.1.1
log
@WCSLIB 6.4 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 6.4 2019/08/15 09:30:18 mcalabre Exp $
@


6.4.1.2
log
@Consequent on warnings from gcc 9.2.0 with -Wstringop-truncation (via -Wall),
replaced use of strncpy() with memcpy().
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 6.4.1.1 2019/08/15 09:31:29 mcalabre Exp mcalabre $
d138 2
a139 2
  memcpy(&CTYPE[1][5], "ARC", 3);
  memcpy(&CTYPE[3][5], "ARC", 3);
d144 2
a145 2
  memcpy(&CTYPE[1][5], "ZEA", 3);
  memcpy(&CTYPE[3][5], "ZEA", 3);
d150 2
a151 2
  memcpy(&CTYPE[1][5], "CYP", 3);
  memcpy(&CTYPE[3][5], "CYP", 3);
d158 2
a159 2
  memcpy(&CTYPE[1][5], "CEA", 3);
  memcpy(&CTYPE[3][5], "CEA", 3);
d165 2
a166 2
  memcpy(&CTYPE[1][5], "CAR", 3);
  memcpy(&CTYPE[3][5], "CAR", 3);
d171 2
a172 2
  memcpy(&CTYPE[1][5], "SFL", 3);
  memcpy(&CTYPE[3][5], "SFL", 3);
d177 2
a178 2
  memcpy(&CTYPE[1][5], "PAR", 3);
  memcpy(&CTYPE[3][5], "PAR", 3);
d183 2
a184 2
  memcpy(&CTYPE[1][5], "MOL", 3);
  memcpy(&CTYPE[3][5], "MOL", 3);
d189 2
a190 2
  memcpy(&CTYPE[1][5], "AIT", 3);
  memcpy(&CTYPE[3][5], "AIT", 3);
d195 2
a196 2
  memcpy(&CTYPE[1][5], "COE", 3);
  memcpy(&CTYPE[3][5], "COE", 3);
d203 2
a204 2
  memcpy(&CTYPE[1][5], "COD", 3);
  memcpy(&CTYPE[3][5], "COD", 3);
d211 2
a212 2
  memcpy(&CTYPE[1][5], "BON", 3);
  memcpy(&CTYPE[3][5], "BON", 3);
d218 2
a219 2
  memcpy(&CTYPE[1][5], "PCO", 3);
  memcpy(&CTYPE[3][5], "PCO", 3);
d224 2
a225 2
  memcpy(&CTYPE[1][5], "TSC", 3);
  memcpy(&CTYPE[3][5], "TSC", 3);
d230 2
a231 2
  memcpy(&CTYPE[1][5], "QSC", 3);
  memcpy(&CTYPE[3][5], "QSC", 3);
@


6.4.1.3
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2020, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 6.4.1.2 2019/12/03 06:14:52 mcalabre Exp mcalabre $
@


6.3
log
@WCSLIB 6.3
@
text
@d3 1
a3 1
  WCSLIB 6.3 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 6.2.1.2 2019/05/10 02:01:28 mcalabre Exp mcalabre $
@


6.3.1.1
log
@WCSLIB 6.3 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 6.3 2019/07/12 07:33:39 mcalabre Exp $
@


6.2
log
@WCSLIB 6.2
@
text
@d3 2
a4 2
  WCSLIB 6.2 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2018, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 6.1.1.1 2018/10/19 08:36:15 mcalabre Exp mcalabre $
@


6.2.1.1
log
@WCSLIB 6.2 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 6.2 2018/10/20 10:03:14 mcalabre Exp $
@


6.2.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2019, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 6.2.1.1 2018/10/20 10:04:15 mcalabre Exp mcalabre $
@


6.1
log
@WCSLIB 6.1
@
text
@d3 1
a3 1
  WCSLIB 6.1 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.20.1.1 2018/10/05 05:33:33 mcalabre Exp mcalabre $
@


6.1.1.1
log
@WCSLIB 6.1 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 6.1 2018/10/19 08:35:17 mcalabre Exp $
@


5.20
log
@WCSLIB 5.20
@
text
@d3 1
a3 1
  WCSLIB 5.20 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.19.1.1 2018/07/26 15:41:41 mcalabre Exp mcalabre $
@


5.20.1.1
log
@WCSLIB 5.20 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.20 2018/10/05 05:32:41 mcalabre Exp $
@


5.19
log
@WCSLIB 5.19
@
text
@d3 1
a3 1
  WCSLIB 5.19 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.18.1.1 2018/01/10 08:33:04 mcalabre Exp mcalabre $
@


5.19.1.1
log
@WCSLIB 5.19 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.19 2018/07/26 15:37:05 mcalabre Exp $
@


5.18
log
@WCSLIB 5.18
@
text
@d3 1
a3 1
  WCSLIB 5.18 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.17.1.2 2018/01/10 08:26:04 mcalabre Exp mcalabre $
@


5.18.1.1
log
@WCSLIB 5.18 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.18 2018/01/10 08:32:14 mcalabre Exp $
@


5.17
log
@WCSLIB 5.17
@
text
@d3 2
a4 2
  WCSLIB 5.17 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2017, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 5.16.1.1 2017/01/15 04:29:01 mcalabre Exp mcalabre $
@


5.17.1.1
log
@WCSLIB 5.17 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.17 2017/09/18 08:44:24 mcalabre Exp $
@


5.17.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2018, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 5.17.1.1 2017/09/18 08:46:00 mcalabre Exp mcalabre $
@


5.16
log
@WCSLIB 5.16
@
text
@d3 1
a3 1
  WCSLIB 5.16 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.15.1.2 2017/01/15 04:14:22 mcalabre Exp mcalabre $
@


5.16.1.1
log
@WCSLIB 5.16 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.16 2017/01/15 04:25:02 mcalabre Exp $
@


5.15
log
@WCSLIB 5.15
@
text
@d3 2
a4 2
  WCSLIB 5.15 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2016, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 5.14.1.1 2016/02/07 10:52:46 mcalabre Exp mcalabre $
@


5.15.1.1
log
@WCSLIB 5.15 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.15 2016/04/05 12:55:11 mcalabre Exp $
@


5.15.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2017, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 5.15.1.1 2016/04/05 12:58:37 mcalabre Exp mcalabre $
@


5.14
log
@WCSLIB 5.14
@
text
@d3 1
a3 1
  WCSLIB 5.14 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.13.1.1 2016/01/26 08:54:34 mcalabre Exp mcalabre $
@


5.14.1.1
log
@WCSLIB 5.14 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.14 2016/02/07 10:49:32 mcalabre Exp $
@


5.13
log
@WCSLIB 5.13
@
text
@d3 1
a3 1
  WCSLIB 5.13 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.12.1.2 2016/01/25 05:17:40 mcalabre Exp mcalabre $
@


5.13.1.1
log
@WCSLIB 5.13 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.13 2016/01/26 08:51:15 mcalabre Exp $
@


5.12
log
@WCSLIB 5.12
@
text
@d3 2
a4 2
  WCSLIB 5.12 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2015, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 5.11.1.1 2015/10/18 09:16:29 mcalabre Exp mcalabre $
@


5.12.1.1
log
@WCSLIB 5.12 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.12 2015/11/15 02:13:01 mcalabre Exp $
@


5.12.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2016, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 5.12.1.1 2015/11/15 02:16:16 mcalabre Exp mcalabre $
@


5.11
log
@WCSLIB 5.11
@
text
@d3 1
a3 1
  WCSLIB 5.11 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.10.1.1 2015/10/09 08:22:37 mcalabre Exp mcalabre $
@


5.11.1.1
log
@WCSLIB 5.11 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.11 2015/10/18 09:13:06 mcalabre Exp $
@


5.10
log
@WCSLIB 5.10
@
text
@d3 1
a3 1
  WCSLIB 5.10 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.9.1.1 2015/07/21 09:28:10 mcalabre Exp mcalabre $
@


5.10.1.1
log
@WCSLIB 5.10 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.10 2015/10/09 08:19:16 mcalabre Exp $
@


5.9
log
@WCSLIB 5.9
@
text
@d3 1
a3 1
  WCSLIB 5.9 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.8.1.1 2015/07/08 11:07:20 mcalabre Exp mcalabre $
@


5.9.1.1
log
@WCSLIB 5.9 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.9 2015/07/21 09:20:03 mcalabre Exp $
@


5.8
log
@WCSLIB 5.8
@
text
@d3 1
a3 1
  WCSLIB 5.8 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.7.1.1 2015/06/29 02:47:25 mcalabre Exp mcalabre $
@


5.8.1.1
log
@WCSLIB 5.8 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.8 2015/07/08 11:04:01 mcalabre Exp $
@


5.7
log
@WCSLIB 5.7
@
text
@d3 1
a3 1
  WCSLIB 5.7 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.6.1.1 2015/06/14 07:14:46 mcalabre Exp mcalabre $
@


5.7.1.1
log
@WCSLIB 5.7 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.7 2015/06/29 02:44:17 mcalabre Exp $
@


5.6
log
@WCSLIB 5.6
@
text
@d3 1
a3 1
  WCSLIB 5.6 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.5.1.1 2015/05/05 13:21:02 mcalabre Exp mcalabre $
@


5.6.1.1
log
@WCSLIB 5.6 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.6 2015/06/14 07:11:25 mcalabre Exp $
@


5.5
log
@WCSLIB 5.5
@
text
@d3 1
a3 1
  WCSLIB 5.5 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.4.1.1 2015/04/21 14:44:29 mcalabre Exp mcalabre $
@


5.5.1.1
log
@WCSLIB 5.5 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.5 2015/05/05 13:16:32 mcalabre Exp $
@


5.4
log
@WCSLIB 5.4
@
text
@d3 1
a3 1
  WCSLIB 5.4 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.3.1.1 2015/04/21 02:54:03 mcalabre Exp mcalabre $
@


5.4.1.1
log
@WCSLIB 5.4 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.4 2015/04/21 14:41:06 mcalabre Exp $
@


5.3
log
@WCSLIB 5.3
@
text
@d3 1
a3 1
  WCSLIB 5.3 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.2.1.1 2015/04/15 12:39:16 mcalabre Exp mcalabre $
@


5.3.1.1
log
@WCSLIB 5.3 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.3 2015/04/21 02:50:52 mcalabre Exp $
@


5.2
log
@WCSLIB 5.2
@
text
@d3 1
a3 1
  WCSLIB 5.2 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.1.1.1 2015/04/07 11:01:11 mcalabre Exp mcalabre $
@


5.2.1.1
log
@WCSLIB 5.2 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.2 2015/04/15 12:35:08 mcalabre Exp $
@


5.1
log
@WCSLIB 5.1
@
text
@d3 1
a3 1
  WCSLIB 5.1 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 5.0.1.1 2015/04/05 12:28:02 mcalabre Exp mcalabre $
@


5.1.1.1
log
@WCSLIB 5.1 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.1 2015/04/07 10:56:38 mcalabre Exp $
@


5.0
log
@WCSLIB 5.0
@
text
@d3 1
a3 1
  WCSLIB 5.0 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.25.1.3 2015/03/06 03:41:16 mcalabre Exp mcalabre $
@


5.0.1.1
log
@WCSLIB 5.0 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 5.0 2015/04/05 12:25:01 mcalabre Exp $
@


4.25
log
@WCSLIB 4.25
@
text
@d3 2
a4 2
  WCSLIB 4.25 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2014, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 4.24.1.1 2014/09/18 15:28:11 mcalabre Exp mcalabre $
d641 2
@


4.25.1.1
log
@WCSLIB 4.25 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.25 2014/12/14 14:29:37 mcalabre Exp $
@


4.25.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2015, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 4.25.1.1 2014/12/14 14:32:46 mcalabre Exp mcalabre $
@


4.25.1.3
log
@In grdplt(), call wcsfree(native) to avoid memory leak reports from
valgrind.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.25.1.2 2015/01/06 01:01:52 mcalabre Exp mcalabre $
a640 2

  wcsfree(&native);
@


4.24
log
@WCSLIB 4.24
@
text
@d3 1
a3 1
  WCSLIB 4.24 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.23.1.1 2014/05/13 05:53:51 mcalabre Exp mcalabre $
@


4.24.1.1
log
@WCSLIB 4.24 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.24 2014/09/18 15:25:01 mcalabre Exp $
@


4.23
log
@WCSLIB 4.23
@
text
@d3 1
a3 1
  WCSLIB 4.23 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.22.1.1 2014/04/12 15:06:33 mcalabre Exp mcalabre $
@


4.23.1.1
log
@WCSLIB 4.23 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.23 2014/05/13 05:50:52 mcalabre Exp $
@


4.22
log
@WCSLIB 4.22
@
text
@d3 1
a3 1
  WCSLIB 4.22 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.21.1.1 2014/03/24 05:15:29 mcalabre Exp mcalabre $
@


4.22.1.1
log
@WCSLIB 4.22 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.22 2014/04/12 15:03:53 mcalabre Exp $
@


4.21
log
@WCSLIB 4.21
@
text
@d3 1
a3 1
  WCSLIB 4.21 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.20.1.2 2014/03/21 06:26:03 mcalabre Exp mcalabre $
@


4.21.1.1
log
@WCSLIB 4.21 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.21 2014/03/24 05:12:28 mcalabre Exp $
@


4.20
log
@WCSLIB 4.20
@
text
@d3 2
a4 2
  WCSLIB 4.20 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2013, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 4.19.1.1 2013/09/29 14:20:40 mcalabre Exp mcalabre $
@


4.20.1.1
log
@WCSLIB 4.20 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.20 2013/12/18 05:42:50 mcalabre Exp $
@


4.20.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2014, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 4.20.1.1 2013/12/18 05:46:56 mcalabre Exp mcalabre $
@


4.19
log
@WCSLIB 4.19
@
text
@d3 1
a3 1
  WCSLIB 4.19 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.18.1.1 2013/07/13 10:02:38 mcalabre Exp mcalabre $
@


4.19.1.1
log
@WCSLIB 4.19 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.19 2013/09/29 14:17:52 mcalabre Exp $
@


4.18
log
@WCSLIB 4.18
@
text
@d3 1
a3 1
  WCSLIB 4.18 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.17.1.1 2013/01/29 05:32:33 cal103 Exp cal103 $
@


4.18.1.1
log
@WCSLIB 4.18 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.18 2013/07/13 10:00:05 mcalabre Exp $
@


4.17
log
@WCSLIB 4.17
@
text
@d3 1
a3 1
  WCSLIB 4.17 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.16.1.2 2013/01/29 05:10:40 cal103 Exp cal103 $
@


4.17.1.1
log
@WCSLIB 4.17 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.17 2013/01/29 05:29:21 cal103 Exp $
@


4.16
log
@WCSLIB 4.16
@
text
@d3 2
a4 2
  WCSLIB 4.16 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2012, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 4.15.1.1 2012/09/26 14:27:52 cal103 Exp cal103 $
@


4.16.1.1
log
@WCSLIB 4.16 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.16 2012/11/07 04:42:45 cal103 Exp $
@


4.16.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2013, Mark Calabretta
d25 1
a25 1
  $Id: twcsmix.c,v 4.16.1.1 2012/11/07 04:45:57 cal103 Exp cal103 $
@


4.15
log
@WCSLIB 4.15
@
text
@d3 1
a3 1
  WCSLIB 4.15 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.14.1.1 2012/07/13 10:04:50 cal103 Exp cal103 $
@


4.15.1.1
log
@WCSLIB 4.15 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.15 2012/09/26 14:26:06 cal103 Exp $
@


4.14
log
@WCSLIB 4.14
@
text
@d3 1
a3 1
  WCSLIB 4.14 - an implementation of the FITS WCS standard.
d25 1
a25 1
  $Id: twcsmix.c,v 4.13.1.2 2012/07/13 03:37:00 cal103 Exp cal103 $
@


4.14.1.1
log
@WCSLIB 4.14 development branch.
@
text
@d25 1
a25 1
  $Id: twcsmix.c,v 4.14 2012/07/13 10:02:32 cal103 Exp $
@


4.13
log
@WCSLIB 4.13
@
text
@d3 1
a3 1
  WCSLIB 4.13 - an implementation of the FITS WCS standard.
d19 1
a19 1
  along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.
d21 5
a25 11
  Correspondence concerning WCSLIB may be directed to:
    Internet email: mcalabre@@atnf.csiro.au
    Postal address: Dr. Mark Calabretta
                    Australia Telescope National Facility, CSIRO
                    PO Box 76
                    Epping NSW 1710
                    AUSTRALIA

  Author: Mark Calabretta, Australia Telescope National Facility
  http://www.atnf.csiro.au/~mcalabre/index.html
  $Id: twcsmix.c,v 4.12.1.1 2012/02/29 07:59:11 cal103 Exp cal103 $
@


4.13.1.1
log
@WCSLIB 4.13 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.13 2012/03/14 07:39:30 cal103 Exp $
@


4.13.1.2
log
@Changed contact details.
@
text
@d19 1
a19 1
  along with WCSLIB.  If not, see http://www.gnu.org/licenses.
d21 11
a31 5
  Direct correspondence concerning WCSLIB to mark@@calabretta.id.au

  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
  http://www.atnf.csiro.au/people/Mark.Calabretta
  $Id: twcsmix.c,v 4.13.1.1 2012/03/14 07:40:38 cal103 Exp cal103 $
@


4.12
log
@WCSLIB 4.12
@
text
@d3 1
a3 1
  WCSLIB 4.12 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: twcsmix.c,v 4.11.1.1 2012/02/20 23:31:13 cal103 Exp cal103 $
@


4.12.1.1
log
@WCSLIB 4.12 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.12 2012/02/29 07:57:57 cal103 Exp $
@


4.11
log
@WCSLIB 4.11
@
text
@d3 1
a3 1
  WCSLIB 4.11 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: twcsmix.c,v 4.10.1.1 2012/02/05 23:42:47 cal103 Exp cal103 $
@


4.11.1.1
log
@WCSLIB 4.11 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.11 2012/02/20 23:30:02 cal103 Exp $
@


4.10
log
@WCSLIB 4.10
@
text
@d3 1
a3 1
  WCSLIB 4.10 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: twcsmix.c,v 4.9.1.1 2012/01/24 05:41:46 cal103 Exp cal103 $
@


4.10.1.1
log
@WCSLIB 4.10 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.10 2012/02/05 23:41:44 cal103 Exp $
@


4.9
log
@WCSLIB 4.9
@
text
@d3 1
a3 1
  WCSLIB 4.9 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: twcsmix.c,v 4.8.1.2 2012/01/24 05:23:30 cal103 Exp cal103 $
@


4.9.1.1
log
@WCSLIB 4.9 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.9 2012/01/24 05:40:29 cal103 Exp $
@


4.8
log
@WCSLIB 4.8
@
text
@d3 2
a4 2
  WCSLIB 4.8 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2011, Mark Calabretta
d31 1
a31 1
  $Id: twcsmix.c,v 4.7.1.1 2011/02/07 07:04:23 cal103 Exp cal103 $
@


4.8.1.1
log
@WCSLIB 4.8 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.8 2011/08/15 08:05:54 cal103 Exp $
@


4.8.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2012, Mark Calabretta
d31 1
a31 1
  $Id: twcsmix.c,v 4.8.1.1 2011/08/15 08:07:06 cal103 Exp cal103 $
@


4.7
log
@WCSLIB 4.7
@
text
@d3 1
a3 1
  WCSLIB 4.7 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: twcsmix.c,v 4.6.1.2 2011/01/14 06:33:44 cal103 Exp cal103 $
@


4.7.1.1
log
@WCSLIB 4.7 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.7 2011/02/07 07:03:42 cal103 Exp $
@


4.6
log
@WCSLIB 4.6
@
text
@d3 2
a4 2
  WCSLIB 4.6 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2010, Mark Calabretta
d31 1
a31 1
  $Id: twcsmix.c,v 4.5.1.1 2010/07/16 07:05:32 cal103 Exp cal103 $
@


4.6.1.1
log
@WCSLIB 4.6 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.6 2010/11/16 06:15:31 cal103 Exp $
@


4.6.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2011, Mark Calabretta
d31 1
a31 1
  $Id: twcsmix.c,v 4.6.1.1 2010/11/16 06:16:19 cal103 Exp cal103 $
@


4.5
log
@WCSLIB 4.5
@
text
@d3 1
a3 1
  WCSLIB 4.5 - an implementation of the FITS WCS standard.
d31 1
a31 1
  $Id: twcsmix.c,v 4.4.1.2 2010/01/19 03:44:00 cal103 Exp cal103 $
@


4.5.1.1
log
@WCSLIB 4.5 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.5 2010/07/16 07:01:26 cal103 Exp $
@


4.4
log
@WCSLIB 4.4
@
text
@d3 2
a4 2
  WCSLIB 4.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2009, Mark Calabretta
d31 1
a31 1
  $Id: twcsmix.c,v 4.3.1.2 2009/07/22 06:38:03 cal103 Exp cal103 $
@


4.4.1.1
log
@WCSLIB 4.4 development branch.
@
text
@d31 1
a31 1
  $Id: twcsmix.c,v 4.4 2009/08/06 07:45:31 cal103 Exp $
@


4.4.1.2
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
  Copyright (C) 1995-2010, Mark Calabretta
d31 1
a31 1
  $Id: twcsmix.c,v 4.4.1.1 2009/08/10 08:54:26 cal103 Exp cal103 $
@


4.3
log
@WCSLIB 4.3
@
text
@d3 2
a4 2
    WCSLIB 4.3 - an implementation of the FITS WCS standard.
    Copyright (C) 1995-2007, Mark Calabretta
d6 1
a6 1
    This file is part of WCSLIB.
d8 24
a31 24
    WCSLIB is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
    more details.

    You should have received a copy of the GNU Lesser General Public License
    along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.

    Correspondence concerning WCSLIB may be directed to:
       Internet email: mcalabre@@atnf.csiro.au
       Postal address: Dr. Mark Calabretta
                       Australia Telescope National Facility, CSIRO
                       PO Box 76
                       Epping NSW 1710
                       AUSTRALIA

    Author: Mark Calabretta, Australia Telescope National Facility
    http://www.atnf.csiro.au/~mcalabre/index.html
    $Id: twcsmix.c,v 4.2.1.5 2007/12/03 05:12:59 cal103 Exp $
d34 4
a37 4
*   twcs2 tests wcsmix() for closure on the 1 degree celestial graticule for
*   a number of selected projections.  Points with good solutions are marked
*   with a white dot on a graphical display of the projection while bad
*   solutions are flagged with a red circle.
d87 2
a88 2
   char   text[80];
   register int status;
d91 2
a92 2
   printf("Testing WCSLIB wcsmix() routine (twcsmix.c)\n"
          "-------------------------------------------\n");
d94 146
a239 146
   /* List status return messages. */
   printf("\nList of wcs status return values:\n");
   for (status = 1; status <= 13; status++) {
      printf("%4d: %s.\n", status, wcs_errmsg[status]);
   }


   /* PGPLOT initialization. */
   strcpy(text, "/xwindow");
   cpgbeg(0, text, 1, 1);

   /* Define pen colours. */
   cpgscr(0, 0.00f, 0.00f, 0.00f);
   cpgscr(1, 1.00f, 1.00f, 0.00f);
   cpgscr(2, 1.00f, 1.00f, 1.00f);
   cpgscr(3, 0.50f, 0.50f, 0.80f);
   cpgscr(4, 0.80f, 0.50f, 0.50f);
   cpgscr(5, 0.80f, 0.80f, 0.80f);
   cpgscr(6, 0.50f, 0.50f, 0.80f);
   cpgscr(7, 0.80f, 0.50f, 0.50f);
   cpgscr(8, 0.30f, 0.50f, 0.30f);
   cpgscr(9, 1.00f, 0.75f, 0.00f);


   /*----------------------------------------------------------*/
   /* Set the PVi_m keyvalues for the longitude axis so that   */
   /* the fiducial native coordinates are at the native pole,  */
   /* i.e. (phi0,theta0) = (0,90), but without any fiducial    */
   /* offset.  We do this as a test, and also so that all      */
   /* projections will be exercised with the same obliquity    */
   /* parameters.                                              */
   /*----------------------------------------------------------*/
   PV[0].i = 4;			/* Longitude is on axis 4.     */
   PV[0].m = 1;			/* Parameter number 1.         */
   PV[0].value =  0.0;		/* Fiducial native longitude.  */

   PV[1].i = 4;			/* Longitude is on axis 4.     */
   PV[1].m = 2;			/* Parameter number 2.         */
   PV[1].value = 90.0;		/* Fiducial native latitude.   */

   /* Set the PVi_m keyvalues for the latitude axis.           */
   PV[2].i = 2;			/* Latitude is on axis 2.      */
   PV[2].m = 1;			/* Parameter number 1.         */
   PV[2].value = 0.0;		/* PVi_1 (set below).          */

   PV[3].i = 2;			/* Latitude is on axis 2.      */
   PV[3].m = 2;			/* Parameter number 2.         */
   PV[3].value = 0.0;		/* PVi_2 (set below).          */

   /* ARC: zenithal/azimuthal equidistant. */
   strncpy(&CTYPE[1][5], "ARC", 3);
   strncpy(&CTYPE[3][5], "ARC", 3);
   NPV = 2;
   mixex(-190.0, 190.0, -190.0, 190.0);

   /* ZEA: zenithal/azimuthal equal area. */
   strncpy(&CTYPE[1][5], "ZEA", 3);
   strncpy(&CTYPE[3][5], "ZEA", 3);
   NPV = 2;
   mixex(-120.0, 120.0, -120.0, 120.0);

   /* CYP: cylindrical perspective. */
   strncpy(&CTYPE[1][5], "CYP", 3);
   strncpy(&CTYPE[3][5], "CYP", 3);
   NPV = 4;
   PV[2].value = 3.0;
   PV[3].value = 0.8;
   mixex(-170.0, 170.0, -170.0, 170.0);

   /* CEA: cylindrical equal area. */
   strncpy(&CTYPE[1][5], "CEA", 3);
   strncpy(&CTYPE[3][5], "CEA", 3);
   NPV = 3;
   PV[2].value = 0.75;
   mixex(-200.0, 200.0, -200.0, 200.0);

   /* CAR: plate carree. */
   strncpy(&CTYPE[1][5], "CAR", 3);
   strncpy(&CTYPE[3][5], "CAR", 3);
   NPV = 2;
   mixex(-210.0, 210.0, -210.0, 210.0);

   /* SFL: Sanson-Flamsteed. */
   strncpy(&CTYPE[1][5], "SFL", 3);
   strncpy(&CTYPE[3][5], "SFL", 3);
   NPV = 2;
   mixex(-190.0, 190.0, -190.0, 190.0);

   /* PAR: parabolic. */
   strncpy(&CTYPE[1][5], "PAR", 3);
   strncpy(&CTYPE[3][5], "PAR", 3);
   NPV = 2;
   mixex(-190.0, 190.0, -190.0, 190.0);

   /* MOL: Mollweide's projection. */
   strncpy(&CTYPE[1][5], "MOL", 3);
   strncpy(&CTYPE[3][5], "MOL", 3);
   NPV = 2;
   mixex(-170.0, 170.0, -170.0, 170.0);

   /* AIT: Hammer-Aitoff. */
   strncpy(&CTYPE[1][5], "AIT", 3);
   strncpy(&CTYPE[3][5], "AIT", 3);
   NPV = 2;
   mixex(-170.0, 170.0, -170.0, 170.0);

   /* COE: conic equal area. */
   strncpy(&CTYPE[1][5], "COE", 3);
   strncpy(&CTYPE[3][5], "COE", 3);
   NPV = 4;
   PV[2].value = 60.0;
   PV[3].value = 15.0;
   mixex(-140.0, 140.0, -120.0, 160.0);

   /* COD: conic equidistant. */
   strncpy(&CTYPE[1][5], "COD", 3);
   strncpy(&CTYPE[3][5], "COD", 3);
   NPV = 4;
   PV[2].value = 60.0;
   PV[3].value = 15.0;
   mixex(-200.0, 200.0, -180.0, 220.0);

   /* BON: Bonne's projection. */
   strncpy(&CTYPE[1][5], "BON", 3);
   strncpy(&CTYPE[3][5], "BON", 3);
   NPV = 3;
   PV[2].value = 30.0;
   mixex(-160.0, 160.0, -160.0, 160.0);

   /* PCO: polyconic. */
   strncpy(&CTYPE[1][5], "PCO", 3);
   strncpy(&CTYPE[3][5], "PCO", 3);
   NPV = 2;
   mixex(-190.0, 190.0, -190.0, 190.0);

   /* TSC: tangential spherical cube. */
   strncpy(&CTYPE[1][5], "TSC", 3);
   strncpy(&CTYPE[3][5], "TSC", 3);
   NPV = 2;
   mixex(-340.0, 80.0, -210.0, 210.0);

   /* QSC: quadrilateralized spherical cube. */
   strncpy(&CTYPE[1][5], "QSC", 3);
   strncpy(&CTYPE[3][5], "QSC", 3);
   NPV = 2;
   mixex(-340.0, 80.0, -210.0, 210.0);
d241 1
a241 1
   cpgend();
d243 1
a243 1
   return 0;
d256 8
a263 73
   int    doid, lat, lng, wcslat, wcslng, stat, status;
   float  ipt[1], jpt[1];
   double lng1, lat1, phi, theta;
   double latspan[2], lngspan[2];
   double img[4], pix1[4], pix2[4], pix3[4], world[4];
   double pixlng, pixlat, *worldlat, *worldlng;
   struct wcsprm wcs;
   struct prjprm *wcsprj = &(wcs.cel.prj);


   /* This routine simulates the actions of a FITS header parser. */
   wcs.flag = -1;
   parser(&wcs);


   /* Draw the coordinate graticule. */
   grdplt(&wcs, imin, imax, jmin, jmax);
   if (skip_wcsmix) return;


   printf("Testing %s; reporting tolerance %5.1g deg.\n", wcsprj->code, tol);

   /* Cache frequently used values. */
   wcslng = wcs.lng;
   wcslat = wcs.lat;
   worldlng = world + wcslng;
   worldlat = world + wcslat;

   world[0] = 0.0;
   world[1] = 0.0;
   world[2] = 0.0;
   world[3] = 0.0;

   world[wcs.spec] = 2.99792458e8 / RESTFRQ;

   for (lat = 90; lat >= -90; lat--) {
      lat1 = (double)lat;

      for (lng = -180; lng <= 180; lng+=15) {
         lng1 = (double)lng;

         *worldlng = lng1;
         *worldlat = lat1;
         if ((status = wcss2p(&wcs, 1, 4, world, &phi, &theta, img, pix1,
                              &stat))) {
            printf("%3s(s2x): lng1 =%20.15f  lat1 =%20.15f  ERROR %3d\n",
               wcsprj->code, lng1, lat1, status);
            continue;
         }

         pixlng = pix1[wcslng];
         pixlat = pix1[wcslat];

         ipt[0] = pixlng;
         jpt[0] = pixlat;
         cpgpt(1, ipt, jpt, -1);

         lngspan[0] = lng1 - 9.3;
         if (lngspan[0] < -180.0) lngspan[0] = -180.0;
         lngspan[1] = lng1 + 4.1;
         if (lngspan[1] >  180.0) lngspan[1] =  180.0;
         latspan[0] = lat1 - 3.7;
         if (latspan[0] <  -90.0) latspan[0] =  -90.0;
         latspan[1] = lat1 + 7.2;
         if (latspan[1] >   90.0) latspan[1] =   90.0;

         doid = 1;

         pix2[wcslng] = pixlng;
         if ((status = wcsmix(&wcs, wcslng, 1, latspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  A: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);
a264 4
         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  A: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);
d266 3
a268 80
         } else if (fabs(pix3[wcslng]-pixlng) > tol &&
                   (fabs(*worldlat-lat1)  > tol ||
                    fabs(pix2[wcslat]-pixlat) > tol)) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  A: (lng2) =%20.15f   lat2  =%20.15f\n", *worldlng,
               *worldlat);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcslng],
               pix2[wcslat]);
         }


         pix2[wcslat] = pixlat;
         if ((status = wcsmix(&wcs, wcslat, 1, latspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  B: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);

         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                     pix3, &stat))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  B: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);

         } else if (fabs(pix3[wcslat]-pixlat) > tol &&
                   (fabs(*worldlat-lat1)  > tol ||
                    fabs(pix2[wcslng]-pixlng) > tol)) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  B: (lng2) =%20.15f   lat2  =%20.15f\n", *worldlng,
               *worldlat);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcslng],
               pix2[wcslat]);
         }

         *worldlat = lat1;

         pix2[wcslng] = pixlng;
         if ((status = wcsmix(&wcs, wcslng, 2, lngspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  C: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);

         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                     pix3, &stat))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  C: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);

         } else if (fabs(pix3[wcslng]-pixlng) > tol &&
                   (fabs(*worldlng-lng1)  > tol ||
                    fabs(pix2[wcslat]-pixlat) > tol)) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  C:  lng2  =%20.15f  (lat2) =%20.15f\n", *worldlng,
               *worldlat);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcslng],
               pix2[wcslat]);
         }


         pix2[wcslat] = pixlat;
         if ((status = wcsmix(&wcs, wcslat, 2, lngspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  D: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);

         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                     pix3, &stat))) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  D: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);

         } else if (fabs(pix3[wcslat]-pixlat) > tol &&
                   (fabs(*worldlng-lng1)  > tol ||
                    fabs(pix2[wcslng]-pixlng) > tol)) {
            id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
            printf("  D:  lng2  =%20.15f  (lat2) =%20.15f\n", *worldlng,
               *worldlat);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcslng],
               pix2[wcslat]);
         }
a269 2
      }
   }
d271 3
a273 1
   wcsfree(&wcs);
a274 2
   return;
}
d276 1
a276 1
/*--------------------------------------------------------------------------*/
d278 5
a282 1
void id(wcs, doid, lng1, lat1, pixlng, pixlat)
d284 4
a287 3
struct wcsprm *wcs;
int    *doid;
double lng1, lat1, pixlng, pixlat;
d289 1
a289 15
{
   float  ipt[1], jpt[1];
   double phi, theta;
   struct celprm *wcscel = &(wcs->cel);
   struct prjprm *wcsprj = &(wcscel->prj);

   if (*doid) {
      /* Compute native coordinates. */
      sphs2x(wcscel->euler, 1, 1, 1, 1, &lng1, &lat1, &phi, &theta);

      printf("\n%3s:  lng1  =%20.15f   lat1  =%20.15f\n", wcsprj->code, lng1,
         lat1);
      printf(  "       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
      printf(  "        i1  =%20.15f     j1  =%20.15f\n", pixlng, pixlat);
      *doid = 0;
d291 2
a292 6
      cpgsci(9);
      ipt[0] = pixlng;
      jpt[0] = pixlat;
      cpgpt(1, ipt, jpt, 21);
      cpgsci(2);
   }
d294 2
a295 2
   return;
}
d297 8
a304 1
/*--------------------------------------------------------------------------*/
d306 2
a307 1
void grdplt(wcs, imin, imax, jmin, jmax)
d309 3
a311 2
struct wcsprm *wcs;
double imax, imin, jmax, jmin;
d313 16
a328 2
{
#define NELEM 9
d330 4
a333 43
   char   text[80];
   int    ci, ilat, ilng, j, k, stat[361];
   float  fimax, fimin, fjmax, fjmin, ir[1024], jr[1024];
   double freq, img[361][NELEM], lat, lng, phi[361], pix[361][NELEM], step,
          theta[361], world[361][NELEM];
   double *pixlat, *pixlng, *worldlat, *worldlng;
   struct wcsprm native;
   struct celprm *wcscel = &(wcs->cel);
   struct prjprm *wcsprj = &(wcscel->prj);
   struct prjprm *ntvprj = &(native.cel.prj);


   /* Initialize non-celestial world coordinates. */
   freq = 1.42040595e9 - 180.0 * 62500.0;
   for (j = 0; j < 361; j++) {
      world[j][0] = 0.0;
      world[j][1] = 0.0;
      world[j][2] = 0.0;
      world[j][3] = 0.0;

      world[j][wcs->spec] = 2.99792458e8 / freq;
      freq += 62500.0;
   }


   /* Define PGPLOT viewport. */
   fimax = (float)imax;
   fimin = (float)imin;
   fjmax = (float)jmax;
   fjmin = (float)jmin;
   cpgenv(fimin, fimax, fjmin, fjmax, 1, -2);

   /* Draw face boundaries of the quad-cube projections. */
   if (wcsprj->category == QUADCUBE) {
      cpgsci(8);

      /* Draw the map boundary. */
      for (j = 0; j < 9; j++) {
         img[j][0] = 0.0;
         img[j][1] = 0.0;
         img[j][2] = 0.0;
         img[j][3] = 0.0;
      }
d335 9
a343 24
      img[0][wcs->lng] = -wcsprj->w[0];
      img[0][wcs->lat] =  wcsprj->w[0];
      img[1][wcs->lng] = -wcsprj->w[0];
      img[1][wcs->lat] =  wcsprj->w[0]*3.0;
      img[2][wcs->lng] =  wcsprj->w[0];
      img[2][wcs->lat] =  wcsprj->w[0]*3.0;
      img[3][wcs->lng] =  wcsprj->w[0];
      img[3][wcs->lat] = -wcsprj->w[0]*3.0;
      img[4][wcs->lng] = -wcsprj->w[0];
      img[4][wcs->lat] = -wcsprj->w[0]*3.0;
      img[5][wcs->lng] = -wcsprj->w[0];
      img[5][wcs->lat] =  wcsprj->w[0];
      img[6][wcs->lng] =  wcsprj->w[0]*7.0;
      img[6][wcs->lat] =  wcsprj->w[0];
      img[7][wcs->lng] =  wcsprj->w[0]*7.0;
      img[7][wcs->lat] = -wcsprj->w[0];
      img[8][wcs->lng] = -wcsprj->w[0];
      img[8][wcs->lat] = -wcsprj->w[0];

      linx2p(&(wcs->lin), 9, NELEM, img[0], pix[0]);

      for (j = 0; j < 9; j++) {
         ir[j] = pix[j][wcs->lng];
         jr[j] = pix[j][wcs->lat];
a345 2
      cpgline(9, ir, jr);
   }
d347 5
a351 14
   if (wcsprj->category == POLYCONIC) {
      step = 10.0;
   } else {
      step = 15.0;
   }


   /* Draw the native coordinate graticule faintly in the background. */
   native.flag = -1;
   (void)wcscopy(1, wcs, &native);
   native.crval[wcs->lng] =  0.0;
   native.crval[wcs->lat] = 90.0;
   native.lonpole = 180.0;
   (void)wcsset(&native);
d353 4
a356 1
   cpgsci(8);
d358 18
a375 5
   /* Draw native meridians of longitude. */
   for (ilng = -180; ilng <= 180; ilng += 15) {
      lng = (double)ilng;
      if (ilng == -180) lng = -179.99;
      if (ilng ==  180) lng =  179.99;
d377 4
a380 5
      worldlng = world[0] + native.lng;
      worldlat = world[0] + native.lat;
      for (ilat = -90; ilat <= 90; ilat++) {
         *worldlng = lng;
         *worldlat = (double)ilat;
d382 9
a390 2
         worldlng += NELEM;
         worldlat += NELEM;
a392 4
      if (wcss2p(&native, 181, NELEM, world[0], phi, theta, img[0], pix[0],
                 stat)) {
         continue;
      }
d394 5
a398 15
      k = 0;
      pixlng = pix[0] + native.lng;
      pixlat = pix[0] + native.lat;
      for (ilat = -90; ilat <= 90; ilat++) {
         if (ntvprj->category == QUADCUBE && k > 0) {
            if (fabs(*pixlng - ir[k-1]) > 2.0 ||
                fabs(*pixlat - jr[k-1]) > 5.0) {
               if (k > 1) cpgline(k, ir, jr);
               k = 0;
            }
         }

         ir[k] = *pixlng;
         jr[k] = *pixlat;
         k++;
d400 4
a403 17
         pixlng += NELEM;
         pixlat += NELEM;
      }

      cpgline(k, ir, jr);
   }

   /* Draw native parallels of latitude. */
   for (ilat = -90; ilat <= 90; ilat += 15) {
      lat = (double)ilat;

      worldlng = world[0] + native.lng;
      worldlat = world[0] + native.lat;
      for (ilng = -180; ilng <= 180; ilng++) {
         lng = (double)ilng;
         if (ilng == -180) lng = -179.99;
         if (ilng ==  180) lng =  179.99;
d405 9
a413 5
         *worldlng = lng;
         *worldlat = lat;

         worldlng += NELEM;
         worldlat += NELEM;
d416 2
a417 4
      if (wcss2p(&native, 361, NELEM, world[0], phi, theta, img[0], pix[0],
                 stat)) {
         continue;
      }
d419 1
a419 15
      k = 0;
      pixlng = pix[0] + native.lng;
      pixlat = pix[0] + native.lat;
      for (ilng = -180; ilng <= 180; ilng++) {
         if (ntvprj->category == QUADCUBE && k > 0) {
            if (fabs(*pixlng - ir[k-1]) > 2.0 ||
                fabs(*pixlat - jr[k-1]) > 5.0) {
               if (k > 1) cpgline(k, ir, jr);
               k = 0;
            }
         }

         ir[k] = *pixlng;
         jr[k] = *pixlat;
         k++;
d421 2
a422 3
         pixlng += NELEM;
         pixlat += NELEM;
      }
d424 1
a424 2
      cpgline(k, ir, jr);
   }
d426 1
d428 3
a430 2
   /* Draw a colour-coded celestial coordinate graticule. */
   ci = 1;
d432 22
a453 3
   /* Draw celestial meridians of longitude. */
   for (ilng = -180; ilng <= 180; ilng += 15) {
      lng = (double)ilng;
d455 2
a456 2
      if (++ci > 7) ci = 2;
      cpgsci(ilng?ci:1);
d458 1
a458 4
      worldlng = world[0] + wcs->lng;
      worldlat = world[0] + wcs->lat;
      for (ilat = -90; ilat <= 90; ilat++) {
         lat = (double)ilat;
d460 1
a460 2
         *worldlng = lng;
         *worldlat = lat;
d462 2
a463 3
         worldlng += NELEM;
         worldlat += NELEM;
      }
d465 2
a466 4
      if (wcss2p(wcs, 181, NELEM, world[0], phi, theta, img[0], pix[0],
                 stat)) {
         continue;
      }
d468 144
a611 20
      k = 0;
      pixlng = pix[0] + wcs->lng;
      pixlat = pix[0] + wcs->lat;
      for (ilat = -90; ilat <= 90; ilat++) {
         /* Test for discontinuities. */
         if (k > 0) {
            if (fabs(*pixlng - ir[k-1]) > step ||
                fabs(*pixlat - jr[k-1]) > step) {
               if (k > 1) cpgline(k, ir, jr);
               k = 0;
            }
         }

         ir[k] = *pixlng;
         jr[k] = *pixlat;
         k++;

         pixlng += NELEM;
         pixlat += NELEM;
      }
d613 2
a614 2
      cpgline(k, ir, jr);
   }
d616 46
a661 3
   /* Draw celestial parallels of latitude. */
   ci = 1;
   for (ilat = -90; ilat <= 90; ilat += 15) {
d664 2
a665 2
      if (++ci > 7) ci = 2;
      cpgsci(ilat?ci:1);
d667 45
a711 40
      worldlng = world[0] + wcs->lng;
      worldlat = world[0] + wcs->lat;
      for (ilng = -180; ilng <= 180; ilng++) {
         lng = (double)ilng;

         *worldlng = lng;
         *worldlat = lat;

         worldlng += NELEM;
         worldlat += NELEM;
      }

      if (wcss2p(wcs, 361, NELEM, world[0], phi, theta, img[0], pix[0],
                 stat)) {
         continue;
      }

      k = 0;
      pixlng = pix[0] + wcs->lng;
      pixlat = pix[0] + wcs->lat;
      for (ilng = -180; ilng <= 180; ilng++) {
         /* Test for discontinuities. */
         if (k > 0) {
            if (fabs(*pixlng - ir[k-1]) > step ||
                fabs(*pixlat - jr[k-1]) > step) {
               if (k > 1) cpgline(k, ir, jr);
               k = 0;
            }
         }

         ir[k] = *pixlng;
         jr[k] = *pixlat;
         k++;

         pixlng += NELEM;
         pixlat += NELEM;
      }

      cpgline(k, ir, jr);
   }
d713 2
d716 52
a767 6
   /* Write a descriptive title. */
   cpgsci(1);
   sprintf(text, "%s projection - 15 degree graticule", wcsprj->code);
   printf("\n\n%s\n", text);
   fjmin = jmin - 10.0;
   cpgtext(fimin, fjmin, text);
d769 1
a769 5
   sprintf(text, "centered on celestial coordinates (%6.2f,%6.2f)",
      wcscel->ref[0], wcscel->ref[1]);
   printf("%s\n", text);
   fjmin = jmin - 20.0;
   cpgtext(fimin, fjmin, text);
a770 5
   sprintf(text, "with celestial pole at native coordinates (%7.2f,%7.2f)",
      wcscel->ref[2], wcscel->ref[3]);
   printf("%s\n", text);
   fjmin = jmin - 30.0;
   cpgtext(fimin, fjmin, text);
d772 1
a772 4
   cpgsci(2);


   return;
d782 2
a783 48
   int i, j, status;
   double *pcij;

   /* In practice a parser would read the FITS header until it encountered  */
   /* the NAXIS keyword which must occur near the start, before any of the  */
   /* WCS keywords.  It would then use wcsini() to allocate memory for      */
   /* arrays in the wcsprm struct and set default values.  In this          */
   /* simulation the header keyvalues are set as global variables.          */
   wcsini(1, NAXIS, wcs);


   /* Now the parser scans the FITS header, identifying WCS keywords and    */
   /* loading their values into the appropriate elements of the wcsprm      */
   /* struct.                                                               */

   for (j = 0; j < NAXIS; j++) {
      wcs->crpix[j] = CRPIX[j];
   }

   pcij = wcs->pc;
   for (i = 0; i < NAXIS; i++) {
      for (j = 0; j < NAXIS; j++) {
         *(pcij++) = PC[i][j];
      }
   }

   for (i = 0; i < NAXIS; i++) {
      wcs->cdelt[i] = CDELT[i];
   }

   for (i = 0; i < NAXIS; i++) {
      strcpy(wcs->ctype[i], &CTYPE[i][0]);
   }

   for (i = 0; i < NAXIS; i++) {
      wcs->crval[i] = CRVAL[i];
   }

   wcs->lonpole = LONPOLE;
   wcs->latpole = LATPOLE;

   wcs->restfrq = RESTFRQ;
   wcs->restwav = RESTWAV;

   wcs->npv = NPV;
   for (i = 0; i < NPV; i++) {
      wcs->pv[i] = PV[i];
   }
d785 50
a834 4
   /* Extract information from the FITS header. */
   if ((status = wcsset(wcs))) {
      printf("wcsset ERROR%3d\n", status);
   }
d836 1
a836 1
   return;
@


4.3.1.1
log
@WCSLIB 4.3 development branch.
@
text
@d3 2
a4 2
    WCSLIB 4.4 - an implementation of the FITS WCS standard.
    Copyright (C) 1995-2008, Mark Calabretta
d31 1
a31 1
    $Id: twcsmix.c,v 4.3 2007/12/27 05:35:51 cal103 Exp cal103 $
@


4.3.1.2
log
@Changed indentation.
@
text
@d3 2
a4 2
  WCSLIB 4.4 - an implementation of the FITS WCS standard.
  Copyright (C) 1995-2009, Mark Calabretta
d6 1
a6 1
  This file is part of WCSLIB.
d8 24
a31 24
  WCSLIB is free software: you can redistribute it and/or modify it under the
  terms of the GNU Lesser General Public License as published by the Free
  Software Foundation, either version 3 of the License, or (at your option)
  any later version.

  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
  more details.

  You should have received a copy of the GNU Lesser General Public License
  along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.

  Correspondence concerning WCSLIB may be directed to:
    Internet email: mcalabre@@atnf.csiro.au
    Postal address: Dr. Mark Calabretta
                    Australia Telescope National Facility, CSIRO
                    PO Box 76
                    Epping NSW 1710
                    AUSTRALIA

  Author: Mark Calabretta, Australia Telescope National Facility
  http://www.atnf.csiro.au/~mcalabre/index.html
  $Id: twcsmix.c,v 4.3.1.1 2007/12/27 13:24:32 cal103 Exp cal103 $
d34 4
a37 4
* twcsmix tests wcsmix() for closure on the 1 degree celestial graticule for
* a number of selected projections.  Points with good solutions are marked
* with a white dot on a graphical display of the projection while bad
* solutions are flagged with a red circle.
d87 2
a88 2
  char   text[80];
  register int status;
d91 2
a92 2
  printf("Testing WCSLIB wcsmix() routine (twcsmix.c)\n"
         "-------------------------------------------\n");
d94 146
a239 146
  /* List status return messages. */
  printf("\nList of wcs status return values:\n");
  for (status = 1; status <= 13; status++) {
    printf("%4d: %s.\n", status, wcs_errmsg[status]);
  }


  /* PGPLOT initialization. */
  strcpy(text, "/xwindow");
  cpgbeg(0, text, 1, 1);

  /* Define pen colours. */
  cpgscr(0, 0.00f, 0.00f, 0.00f);
  cpgscr(1, 1.00f, 1.00f, 0.00f);
  cpgscr(2, 1.00f, 1.00f, 1.00f);
  cpgscr(3, 0.50f, 0.50f, 0.80f);
  cpgscr(4, 0.80f, 0.50f, 0.50f);
  cpgscr(5, 0.80f, 0.80f, 0.80f);
  cpgscr(6, 0.50f, 0.50f, 0.80f);
  cpgscr(7, 0.80f, 0.50f, 0.50f);
  cpgscr(8, 0.30f, 0.50f, 0.30f);
  cpgscr(9, 1.00f, 0.75f, 0.00f);


  /*----------------------------------------------------------*/
  /* Set the PVi_m keyvalues for the longitude axis so that   */
  /* the fiducial native coordinates are at the native pole,  */
  /* i.e. (phi0,theta0) = (0,90), but without any fiducial    */
  /* offset.  We do this as a test, and also so that all      */
  /* projections will be exercised with the same obliquity    */
  /* parameters.                                              */
  /*----------------------------------------------------------*/
  PV[0].i = 4;			/* Longitude is on axis 4.     */
  PV[0].m = 1;			/* Parameter number 1.         */
  PV[0].value =  0.0;		/* Fiducial native longitude.  */

  PV[1].i = 4;			/* Longitude is on axis 4.     */
  PV[1].m = 2;			/* Parameter number 2.         */
  PV[1].value = 90.0;		/* Fiducial native latitude.   */

  /* Set the PVi_m keyvalues for the latitude axis.           */
  PV[2].i = 2;			/* Latitude is on axis 2.      */
  PV[2].m = 1;			/* Parameter number 1.         */
  PV[2].value = 0.0;		/* PVi_1 (set below).          */

  PV[3].i = 2;			/* Latitude is on axis 2.      */
  PV[3].m = 2;			/* Parameter number 2.         */
  PV[3].value = 0.0;		/* PVi_2 (set below).          */

  /* ARC: zenithal/azimuthal equidistant. */
  strncpy(&CTYPE[1][5], "ARC", 3);
  strncpy(&CTYPE[3][5], "ARC", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  /* ZEA: zenithal/azimuthal equal area. */
  strncpy(&CTYPE[1][5], "ZEA", 3);
  strncpy(&CTYPE[3][5], "ZEA", 3);
  NPV = 2;
  mixex(-120.0, 120.0, -120.0, 120.0);

  /* CYP: cylindrical perspective. */
  strncpy(&CTYPE[1][5], "CYP", 3);
  strncpy(&CTYPE[3][5], "CYP", 3);
  NPV = 4;
  PV[2].value = 3.0;
  PV[3].value = 0.8;
  mixex(-170.0, 170.0, -170.0, 170.0);

  /* CEA: cylindrical equal area. */
  strncpy(&CTYPE[1][5], "CEA", 3);
  strncpy(&CTYPE[3][5], "CEA", 3);
  NPV = 3;
  PV[2].value = 0.75;
  mixex(-200.0, 200.0, -200.0, 200.0);

  /* CAR: plate carree. */
  strncpy(&CTYPE[1][5], "CAR", 3);
  strncpy(&CTYPE[3][5], "CAR", 3);
  NPV = 2;
  mixex(-210.0, 210.0, -210.0, 210.0);

  /* SFL: Sanson-Flamsteed. */
  strncpy(&CTYPE[1][5], "SFL", 3);
  strncpy(&CTYPE[3][5], "SFL", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  /* PAR: parabolic. */
  strncpy(&CTYPE[1][5], "PAR", 3);
  strncpy(&CTYPE[3][5], "PAR", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  /* MOL: Mollweide's projection. */
  strncpy(&CTYPE[1][5], "MOL", 3);
  strncpy(&CTYPE[3][5], "MOL", 3);
  NPV = 2;
  mixex(-170.0, 170.0, -170.0, 170.0);

  /* AIT: Hammer-Aitoff. */
  strncpy(&CTYPE[1][5], "AIT", 3);
  strncpy(&CTYPE[3][5], "AIT", 3);
  NPV = 2;
  mixex(-170.0, 170.0, -170.0, 170.0);

  /* COE: conic equal area. */
  strncpy(&CTYPE[1][5], "COE", 3);
  strncpy(&CTYPE[3][5], "COE", 3);
  NPV = 4;
  PV[2].value = 60.0;
  PV[3].value = 15.0;
  mixex(-140.0, 140.0, -120.0, 160.0);

  /* COD: conic equidistant. */
  strncpy(&CTYPE[1][5], "COD", 3);
  strncpy(&CTYPE[3][5], "COD", 3);
  NPV = 4;
  PV[2].value = 60.0;
  PV[3].value = 15.0;
  mixex(-200.0, 200.0, -180.0, 220.0);

  /* BON: Bonne's projection. */
  strncpy(&CTYPE[1][5], "BON", 3);
  strncpy(&CTYPE[3][5], "BON", 3);
  NPV = 3;
  PV[2].value = 30.0;
  mixex(-160.0, 160.0, -160.0, 160.0);

  /* PCO: polyconic. */
  strncpy(&CTYPE[1][5], "PCO", 3);
  strncpy(&CTYPE[3][5], "PCO", 3);
  NPV = 2;
  mixex(-190.0, 190.0, -190.0, 190.0);

  /* TSC: tangential spherical cube. */
  strncpy(&CTYPE[1][5], "TSC", 3);
  strncpy(&CTYPE[3][5], "TSC", 3);
  NPV = 2;
  mixex(-340.0, 80.0, -210.0, 210.0);

  /* QSC: quadrilateralized spherical cube. */
  strncpy(&CTYPE[1][5], "QSC", 3);
  strncpy(&CTYPE[3][5], "QSC", 3);
  NPV = 2;
  mixex(-340.0, 80.0, -210.0, 210.0);
d241 1
a241 1
  cpgend();
d243 1
a243 1
  return 0;
d256 73
a328 8
  int    doid, lat, lng, wcslat, wcslng, stat, status;
  float  ipt[1], jpt[1];
  double lng1, lat1, phi, theta;
  double latspan[2], lngspan[2];
  double img[4], pix1[4], pix2[4], pix3[4], world[4];
  double pixlng, pixlat, *worldlat, *worldlng;
  struct wcsprm wcs;
  struct prjprm *wcsprj = &(wcs.cel.prj);
d330 4
d335 80
a414 3
  /* This routine simulates the actions of a FITS header parser. */
  wcs.flag = -1;
  parser(&wcs);
d416 2
d419 1
a419 3
  /* Draw the coordinate graticule. */
  grdplt(&wcs, imin, imax, jmin, jmax);
  if (skip_wcsmix) return;
d421 2
d424 1
a424 1
  printf("Testing %s; reporting tolerance %5.1g deg.\n", wcsprj->code, tol);
d426 1
a426 5
  /* Cache frequently used values. */
  wcslng = wcs.lng;
  wcslat = wcs.lat;
  worldlng = world + wcslng;
  worldlat = world + wcslat;
d428 3
a430 4
  world[0] = 0.0;
  world[1] = 0.0;
  world[2] = 0.0;
  world[3] = 0.0;
d432 15
a446 1
  world[wcs.spec] = 2.99792458e8 / RESTFRQ;
d448 6
a453 2
  for (lat = 90; lat >= -90; lat--) {
    lat1 = (double)lat;
d455 2
a456 2
    for (lng = -180; lng <= 180; lng+=15) {
      lng1 = (double)lng;
d458 1
a458 8
      *worldlng = lng1;
      *worldlat = lat1;
      if ((status = wcss2p(&wcs, 1, 4, world, &phi, &theta, img, pix1,
                           &stat))) {
        printf("%3s(s2x): lng1 =%20.15f  lat1 =%20.15f  ERROR %3d\n",
          wcsprj->code, lng1, lat1, status);
        continue;
      }
d460 1
a460 2
      pixlng = pix1[wcslng];
      pixlat = pix1[wcslat];
d462 2
a463 3
      ipt[0] = pixlng;
      jpt[0] = pixlat;
      cpgpt(1, ipt, jpt, -1);
d465 2
a466 16
      lngspan[0] = lng1 - 9.3;
      if (lngspan[0] < -180.0) lngspan[0] = -180.0;
      lngspan[1] = lng1 + 4.1;
      if (lngspan[1] >  180.0) lngspan[1] =  180.0;
      latspan[0] = lat1 - 3.7;
      if (latspan[0] <  -90.0) latspan[0] =  -90.0;
      latspan[1] = lat1 + 7.2;
      if (latspan[1] >   90.0) latspan[1] =   90.0;

      doid = 1;

      pix2[wcslng] = pixlng;
      if ((status = wcsmix(&wcs, wcslng, 1, latspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  A: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);
d468 43
a510 4
      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  A: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);
d512 24
a535 9
      } else if (fabs(pix3[wcslng]-pixlng) > tol &&
                (fabs(*worldlat-lat1)  > tol ||
                 fabs(pix2[wcslat]-pixlat) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  A: (lng2) =%20.15f   lat2  =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
d538 19
d558 5
a562 5
      pix2[wcslat] = pixlat;
      if ((status = wcsmix(&wcs, wcslat, 1, latspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  B: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);
d564 9
a572 4
      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  B: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);
d574 4
a577 18
      } else if (fabs(pix3[wcslat]-pixlat) > tol &&
                (fabs(*worldlat-lat1)  > tol ||
                 fabs(pix2[wcslng]-pixlng) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  B: (lng2) =%20.15f   lat2  =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
      }

      *worldlat = lat1;

      pix2[wcslng] = pixlng;
      if ((status = wcsmix(&wcs, wcslng, 2, lngspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  C: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);
d579 15
a593 4
      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  C: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);
d595 2
a596 9
      } else if (fabs(pix3[wcslng]-pixlng) > tol &&
                (fabs(*worldlng-lng1)  > tol ||
                 fabs(pix2[wcslat]-pixlat) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  C:  lng2  =%20.15f  (lat2) =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
d599 13
d613 2
a614 5
      pix2[wcslat] = pixlat;
      if ((status = wcsmix(&wcs, wcslat, 2, lngspan, 1.0, 0, world, &phi,
                           &theta, img, pix2))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  D: wcsmix ERROR %d: %s.\n", status, wcs_errmsg[status]);
d616 3
a618 4
      } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  D: wcss2p ERROR %d: %s.\n", status, wcs_errmsg[status]);
d620 3
a622 9
      } else if (fabs(pix3[wcslat]-pixlat) > tol &&
                (fabs(*worldlng-lng1)  > tol ||
                 fabs(pix2[wcslng]-pixlng) > tol)) {
        id(&wcs, &doid, lng1, lat1, pixlng, pixlat);
        printf("  D:  lng2  =%20.15f  (lat2) =%20.15f\n", *worldlng,
          *worldlat);
        printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
        printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcslng],
          pix2[wcslat]);
d625 15
a639 2
    }
  }
d641 3
a643 1
  wcsfree(&wcs);
d645 2
a646 2
  return;
}
a647 1
/*--------------------------------------------------------------------------*/
d649 2
a650 1
void id(wcs, doid, lng1, lat1, pixlng, pixlat)
d652 3
a654 3
struct wcsprm *wcs;
int    *doid;
double lng1, lat1, pixlng, pixlat;
d656 2
a657 22
{
  float  ipt[1], jpt[1];
  double phi, theta;
  struct celprm *wcscel = &(wcs->cel);
  struct prjprm *wcsprj = &(wcscel->prj);

  if (*doid) {
    /* Compute native coordinates. */
    sphs2x(wcscel->euler, 1, 1, 1, 1, &lng1, &lat1, &phi, &theta);

    printf("\n%3s:  lng1  =%20.15f   lat1  =%20.15f\n", wcsprj->code, lng1,
      lat1);
    printf(  "       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
    printf(  "        i1  =%20.15f     j1  =%20.15f\n", pixlng, pixlat);
    *doid = 0;

    cpgsci(9);
    ipt[0] = pixlng;
    jpt[0] = pixlat;
    cpgpt(1, ipt, jpt, 21);
    cpgsci(2);
  }
d659 4
a662 2
  return;
}
d664 2
a665 1
/*--------------------------------------------------------------------------*/
d667 3
a669 1
void grdplt(wcs, imin, imax, jmin, jmax)
d671 4
a674 2
struct wcsprm *wcs;
double imax, imin, jmax, jmin;
d676 16
a691 2
{
#define NELEM 9
d693 3
a695 144
  char   text[80];
  int    ci, ilat, ilng, j, k, stat[361];
  float  fimax, fimin, fjmax, fjmin, ir[1024], jr[1024];
  double freq, img[361][NELEM], lat, lng, phi[361], pix[361][NELEM], step,
         theta[361], world[361][NELEM];
  double *pixlat, *pixlng, *worldlat, *worldlng;
  struct wcsprm native;
  struct celprm *wcscel = &(wcs->cel);
  struct prjprm *wcsprj = &(wcscel->prj);
  struct prjprm *ntvprj = &(native.cel.prj);


  /* Initialize non-celestial world coordinates. */
  freq = 1.42040595e9 - 180.0 * 62500.0;
  for (j = 0; j < 361; j++) {
    world[j][0] = 0.0;
    world[j][1] = 0.0;
    world[j][2] = 0.0;
    world[j][3] = 0.0;

    world[j][wcs->spec] = 2.99792458e8 / freq;
    freq += 62500.0;
  }


  /* Define PGPLOT viewport. */
  fimax = (float)imax;
  fimin = (float)imin;
  fjmax = (float)jmax;
  fjmin = (float)jmin;
  cpgenv(fimin, fimax, fjmin, fjmax, 1, -2);

  /* Draw face boundaries of the quad-cube projections. */
  if (wcsprj->category == QUADCUBE) {
    cpgsci(8);

    /* Draw the map boundary. */
    for (j = 0; j < 9; j++) {
      img[j][0] = 0.0;
      img[j][1] = 0.0;
      img[j][2] = 0.0;
      img[j][3] = 0.0;
    }

    img[0][wcs->lng] = -wcsprj->w[0];
    img[0][wcs->lat] =  wcsprj->w[0];
    img[1][wcs->lng] = -wcsprj->w[0];
    img[1][wcs->lat] =  wcsprj->w[0]*3.0;
    img[2][wcs->lng] =  wcsprj->w[0];
    img[2][wcs->lat] =  wcsprj->w[0]*3.0;
    img[3][wcs->lng] =  wcsprj->w[0];
    img[3][wcs->lat] = -wcsprj->w[0]*3.0;
    img[4][wcs->lng] = -wcsprj->w[0];
    img[4][wcs->lat] = -wcsprj->w[0]*3.0;
    img[5][wcs->lng] = -wcsprj->w[0];
    img[5][wcs->lat] =  wcsprj->w[0];
    img[6][wcs->lng] =  wcsprj->w[0]*7.0;
    img[6][wcs->lat] =  wcsprj->w[0];
    img[7][wcs->lng] =  wcsprj->w[0]*7.0;
    img[7][wcs->lat] = -wcsprj->w[0];
    img[8][wcs->lng] = -wcsprj->w[0];
    img[8][wcs->lat] = -wcsprj->w[0];

    linx2p(&(wcs->lin), 9, NELEM, img[0], pix[0]);

    for (j = 0; j < 9; j++) {
      ir[j] = pix[j][wcs->lng];
      jr[j] = pix[j][wcs->lat];
    }

    cpgline(9, ir, jr);
  }

  if (wcsprj->category == POLYCONIC) {
    step = 10.0;
  } else {
    step = 15.0;
  }


  /* Draw the native coordinate graticule faintly in the background. */
  native.flag = -1;
  (void)wcscopy(1, wcs, &native);
  native.crval[wcs->lng] =  0.0;
  native.crval[wcs->lat] = 90.0;
  native.lonpole = 180.0;
  (void)wcsset(&native);

  cpgsci(8);

  /* Draw native meridians of longitude. */
  for (ilng = -180; ilng <= 180; ilng += 15) {
    lng = (double)ilng;
    if (ilng == -180) lng = -179.99;
    if (ilng ==  180) lng =  179.99;

    worldlng = world[0] + native.lng;
    worldlat = world[0] + native.lat;
    for (ilat = -90; ilat <= 90; ilat++) {
      *worldlng = lng;
      *worldlat = (double)ilat;

      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(&native, 181, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    k = 0;
    pixlng = pix[0] + native.lng;
    pixlat = pix[0] + native.lat;
    for (ilat = -90; ilat <= 90; ilat++) {
      if (ntvprj->category == QUADCUBE && k > 0) {
        if (fabs(*pixlng - ir[k-1]) > 2.0 ||
          fabs(*pixlat - jr[k-1]) > 5.0) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }

  /* Draw native parallels of latitude. */
  for (ilat = -90; ilat <= 90; ilat += 15) {
    lat = (double)ilat;

    worldlng = world[0] + native.lng;
    worldlat = world[0] + native.lat;
    for (ilng = -180; ilng <= 180; ilng++) {
      lng = (double)ilng;
      if (ilng == -180) lng = -179.99;
      if (ilng ==  180) lng =  179.99;
d697 2
a698 2
      *worldlng = lng;
      *worldlat = lat;
d700 3
a702 46
      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(&native, 361, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    k = 0;
    pixlng = pix[0] + native.lng;
    pixlat = pix[0] + native.lat;
    for (ilng = -180; ilng <= 180; ilng++) {
      if (ntvprj->category == QUADCUBE && k > 0) {
        if (fabs(*pixlng - ir[k-1]) > 2.0 ||
          fabs(*pixlat - jr[k-1]) > 5.0) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }


  /* Draw a colour-coded celestial coordinate graticule. */
  ci = 1;

  /* Draw celestial meridians of longitude. */
  for (ilng = -180; ilng <= 180; ilng += 15) {
    lng = (double)ilng;

    if (++ci > 7) ci = 2;
    cpgsci(ilng?ci:1);

    worldlng = world[0] + wcs->lng;
    worldlat = world[0] + wcs->lat;
    for (ilat = -90; ilat <= 90; ilat++) {
d705 2
a706 2
      *worldlng = lng;
      *worldlat = lat;
d708 48
a755 45
      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(wcs, 181, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    k = 0;
    pixlng = pix[0] + wcs->lng;
    pixlat = pix[0] + wcs->lat;
    for (ilat = -90; ilat <= 90; ilat++) {
      /* Test for discontinuities. */
      if (k > 0) {
        if (fabs(*pixlng - ir[k-1]) > step ||
            fabs(*pixlat - jr[k-1]) > step) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }

  /* Draw celestial parallels of latitude. */
  ci = 1;
  for (ilat = -90; ilat <= 90; ilat += 15) {
    lat = (double)ilat;

    if (++ci > 7) ci = 2;
    cpgsci(ilat?ci:1);

    worldlng = world[0] + wcs->lng;
    worldlat = world[0] + wcs->lat;
    for (ilng = -180; ilng <= 180; ilng++) {
      lng = (double)ilng;
d757 5
a761 2
      *worldlng = lng;
      *worldlat = lat;
d763 5
a767 52
      worldlng += NELEM;
      worldlat += NELEM;
    }

    if (wcss2p(wcs, 361, NELEM, world[0], phi, theta, img[0], pix[0],
               stat)) {
      continue;
    }

    k = 0;
    pixlng = pix[0] + wcs->lng;
    pixlat = pix[0] + wcs->lat;
    for (ilng = -180; ilng <= 180; ilng++) {
      /* Test for discontinuities. */
      if (k > 0) {
        if (fabs(*pixlng - ir[k-1]) > step ||
            fabs(*pixlat - jr[k-1]) > step) {
          if (k > 1) cpgline(k, ir, jr);
          k = 0;
        }
      }

      ir[k] = *pixlng;
      jr[k] = *pixlat;
      k++;

      pixlng += NELEM;
      pixlat += NELEM;
    }

    cpgline(k, ir, jr);
  }


  /* Write a descriptive title. */
  cpgsci(1);
  sprintf(text, "%s projection - 15 degree graticule", wcsprj->code);
  printf("\n\n%s\n", text);
  fjmin = jmin - 10.0;
  cpgtext(fimin, fjmin, text);

  sprintf(text, "centered on celestial coordinates (%6.2f,%6.2f)",
    wcscel->ref[0], wcscel->ref[1]);
  printf("%s\n", text);
  fjmin = jmin - 20.0;
  cpgtext(fimin, fjmin, text);

  sprintf(text, "with celestial pole at native coordinates (%7.2f,%7.2f)",
    wcscel->ref[2], wcscel->ref[3]);
  printf("%s\n", text);
  fjmin = jmin - 30.0;
  cpgtext(fimin, fjmin, text);
d769 1
a769 1
  cpgsci(2);
d772 1
a772 1
  return;
d782 48
a829 2
  int i, j, status;
  double *pcij;
d831 4
a834 50
  /* In practice a parser would read the FITS header until it encountered  */
  /* the NAXIS keyword which must occur near the start, before any of the  */
  /* WCS keywords.  It would then use wcsini() to allocate memory for      */
  /* arrays in the wcsprm struct and set default values.  In this          */
  /* simulation the header keyvalues are set as global variables.          */
  wcsini(1, NAXIS, wcs);


  /* Now the parser scans the FITS header, identifying WCS keywords and    */
  /* loading their values into the appropriate elements of the wcsprm      */
  /* struct.                                                               */

  for (j = 0; j < NAXIS; j++) {
    wcs->crpix[j] = CRPIX[j];
  }

  pcij = wcs->pc;
  for (i = 0; i < NAXIS; i++) {
    for (j = 0; j < NAXIS; j++) {
      *(pcij++) = PC[i][j];
    }
  }

  for (i = 0; i < NAXIS; i++) {
    wcs->cdelt[i] = CDELT[i];
  }

  for (i = 0; i < NAXIS; i++) {
    strcpy(wcs->ctype[i], &CTYPE[i][0]);
  }

  for (i = 0; i < NAXIS; i++) {
    wcs->crval[i] = CRVAL[i];
  }

  wcs->lonpole = LONPOLE;
  wcs->latpole = LATPOLE;

  wcs->restfrq = RESTFRQ;
  wcs->restwav = RESTWAV;

  wcs->npv = NPV;
  for (i = 0; i < NPV; i++) {
    wcs->pv[i] = PV[i];
  }

  /* Extract information from the FITS header. */
  if ((status = wcsset(wcs))) {
    printf("wcsset ERROR%3d\n", status);
  }
d836 1
a836 1
  return;
@


4.2
log
@WCSLIB 4.2: identify the name of the program in the output.
@
text
@d2 30
a31 29
*
*   WCSLIB 4.2 - an implementation of the FITS WCS convention.
*   Copyright (C) 1995-2005, Mark Calabretta
*
*   WCSLIB is free software; you can redistribute it and/or modify it under
*   the terms of the GNU General Public License as published by the Free
*   Software Foundation; either version 2 of the License, or (at your option)
*   any later version.
*
*   WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
*   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
*   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
*   details.
*
*   You should have received a copy of the GNU General Public License along
*   with WCSLIB; if not, write to the Free Software Foundation, Inc.,
*   59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
*
*   Correspondence concerning WCSLIB may be directed to:
*      Internet email: mcalabre@@atnf.csiro.au
*      Postal address: Dr. Mark Calabretta
*                      Australia Telescope National Facility, CSIRO
*                      PO Box 76
*                      Epping NSW 1710
*                      AUSTRALIA
*
*   Author: Mark Calabretta, Australia Telescope National Facility
*   http://www.atnf.csiro.au/~mcalabre/index.html
*   $Id: twcsmix.c,v 4.1 2005/08/25 06:02:39 cal103 Exp cal103 $
d62 1
a62 1
/* In real life these would be encoded as FITS header cards. */
a89 7
   /* Uncomment the following two lines to raise SIGFPE on floating point
    * exceptions for the Sun FORTRAN compiler.  This signal can be caught
    * within 'dbx' by issuing the command "catch FPE".
    */
/* #include <floatingpoint.h> */
/* ieee_handler("set", "common", SIGFPE_ABORT); */

d119 6
a124 5
   /* Set the PVi_m cards for the longitude axis so that the   */
   /* fiducial native coordinates are at the native pole, i.e. */
   /* (phi0,theta0) = (0,90), but without any fiducial offset. */
   /* We do this as a test, and also so that all projections   */
   /* will be exercised with the same obliquity parameters.    */
d134 1
a134 1
   /* Set the PVi_m cards for the latitude axis.               */
d299 2
a300 2
         if (status = wcss2p(&wcs, 1, 4, world, &phi, &theta, img, pix1,
                             &stat)) {
d325 2
a326 2
         if (status = wcsmix(&wcs, wcslng, 1, latspan, 1.0, 0, world, &phi,
                             &theta, img, pix2)) {
d330 2
a331 2
         } else if (status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                 pix3, &stat)) {
d348 2
a349 2
         if (status = wcsmix(&wcs, wcslat, 1, latspan, 1.0, 0, world, &phi,
                             &theta, img, pix2)) {
d353 2
a354 2
         } else if (status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                    pix3, &stat)) {
d372 2
a373 2
         if (status = wcsmix(&wcs, wcslng, 2, lngspan, 1.0, 0, world, &phi,
                             &theta, img, pix2)) {
d377 2
a378 2
         } else if (status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                    pix3, &stat)) {
d395 2
a396 2
         if (status = wcsmix(&wcs, wcslat, 2, lngspan, 1.0, 0, world, &phi,
                             &theta, img, pix2)) {
d400 2
a401 2
         } else if (status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                    pix3, &stat)) {
d786 4
a789 4
   /* the NAXIS card which must occur near the start of the header before   */
   /* any of the WCS keywords.  It would then use wcsini() to allocate      */
   /* memory for arrays in the wcsprm struct and set default values.        */
   /* In this simulation the header keyvalues are set as global variables.  */
d832 1
a832 1
   if (status = wcsset(wcs)) {
@


4.2.1.1
log
@WCSLIB 4.2 development branch.
@
text
@d3 1
a3 1
*   WCSLIB 4.3 - an implementation of the FITS WCS convention.
d30 1
a30 1
*   $Id: twcsmix.c,v 4.2 2005/09/22 02:03:02 cal103 Exp cal103 $
@


4.2.1.2
log
@Removed comment re catching floating point exceptions in SunOS.
@
text
@d30 1
a30 1
*   $Id: twcsmix.c,v 4.2.1.1 2005/12/05 01:39:15 cal103 Exp cal103 $
d88 7
@


4.2.1.3
log
@Parenthesised assignments used as truth values.
@
text
@d4 1
a4 1
*   Copyright (C) 1995-2007, Mark Calabretta
d30 1
a30 1
*   $Id: twcsmix.c,v 4.2.1.2 2005/12/16 03:48:31 cal103 Exp cal103 $
d297 2
a298 2
         if ((status = wcss2p(&wcs, 1, 4, world, &phi, &theta, img, pix1,
                              &stat))) {
d323 2
a324 2
         if ((status = wcsmix(&wcs, wcslng, 1, latspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
d328 2
a329 2
         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                  pix3, &stat))) {
d346 2
a347 2
         if ((status = wcsmix(&wcs, wcslat, 1, latspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
d351 2
a352 2
         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                     pix3, &stat))) {
d370 2
a371 2
         if ((status = wcsmix(&wcs, wcslng, 2, lngspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
d375 2
a376 2
         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                     pix3, &stat))) {
d393 2
a394 2
         if ((status = wcsmix(&wcs, wcslat, 2, lngspan, 1.0, 0, world, &phi,
                              &theta, img, pix2))) {
d398 2
a399 2
         } else if ((status = wcss2p(&wcs, 1, 0, world, &phi, &theta, img,
                                     pix3, &stat))) {
d830 1
a830 1
   if ((status = wcsset(wcs))) {
@


4.2.1.4
log
@Replaced use of the obsolete term "card".
@
text
@d30 1
a30 1
*   $Id: twcsmix.c,v 4.2.1.3 2007/06/29 06:44:21 cal103 Exp cal103 $
d61 1
a61 1
/* In real life these would be encoded as FITS header keyrecords. */
d118 5
a122 6
   /* Set the PVi_m keyvalues for the longitude axis so that   */
   /* the fiducial native coordinates are at the native pole,  */
   /* i.e. (phi0,theta0) = (0,90), but without any fiducial    */
   /* offset.  We do this as a test, and also so that all      */
   /* projections will be exercised with the same obliquity    */
   /* parameters.                                              */
d132 1
a132 1
   /* Set the PVi_m keyvalues for the latitude axis.           */
d784 4
a787 4
   /* the NAXIS keyword which must occur near the start, before any of the  */
   /* WCS keywords.  It would then use wcsini() to allocate memory for      */
   /* arrays in the wcsprm struct and set default values.  In this          */
   /* simulation the header keyvalues are set as global variables.          */
@


4.2.1.5
log
@Switched to LGPL 3.0.
@
text
@d2 29
a30 30

    WCSLIB 4.3 - an implementation of the FITS WCS standard.
    Copyright (C) 1995-2007, Mark Calabretta

    This file is part of WCSLIB.

    WCSLIB is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
    more details.

    You should have received a copy of the GNU Lesser General Public License
    along with WCSLIB.  If not, see <http://www.gnu.org/licenses/>.

    Correspondence concerning WCSLIB may be directed to:
       Internet email: mcalabre@@atnf.csiro.au
       Postal address: Dr. Mark Calabretta
                       Australia Telescope National Facility, CSIRO
                       PO Box 76
                       Epping NSW 1710
                       AUSTRALIA

    Author: Mark Calabretta, Australia Telescope National Facility
    http://www.atnf.csiro.au/~mcalabre/index.html
    $Id: twcsmix.c,v 4.2.1.4 2007/08/02 05:58:54 cal103 Exp cal103 $
@


4.1
log
@WCSLIB 4.1: trivial changes.
@
text
@d3 1
a3 1
*   WCSLIB 4.1 - an implementation of the FITS WCS convention.
d30 1
a30 1
*   $Id: twcsmix.c,v 4.0 2005/02/04 06:26:28 cal103 Exp cal103 $
d97 2
a98 2
   printf("\nTesting WCSLIB wcsmix() routine\n");
   printf("-------------------------------\n");
@


4.0
log
@WCSLIB 4.0: changed from LGPL to GPL.
@
text
@d3 1
a3 1
*   WCSLIB 4.0 - an implementation of the FITS WCS convention.
d30 1
a30 1
*   $Id: twcsmix.c,v 3.6 2004/08/25 05:48:55 cal103 Exp cal103 $
d87 1
a87 1
   register int j;
d102 2
a103 2
   for (j = 1; j <= 11 ; j++) {
      printf("   %2d: %s.\n", j, wcs_errmsg[j]);
d268 1
d281 1
a281 2
   printf("Testing %s; reporting tolerance %5.1g deg.\n", wcs.cel.prj.code,
          tol);
d307 1
a307 1
               wcs.cel.prj.code, lng1, lat1, status);
d333 1
a333 2
            printf("  A: wcsmix ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d338 1
a338 2
            printf("  A: wcss2p ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d356 1
a356 2
            printf("  B: wcsmix ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d361 1
a361 2
            printf("  B: wcss2p ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d380 1
a380 2
            printf("  C: wcsmix ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d385 1
a385 2
            printf("  C: wcss2p ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d403 1
a403 2
            printf("  D: wcsmix ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d408 1
a408 2
            printf("  D: wcss2p ERROR %d, %s.\n", status,
                   wcs_errmsg[status]);
d424 2
d429 1
d440 2
d445 1
a445 1
      sphs2x(wcs->cel.euler, 1, 1, 1, 1, &lng1, &lat1, &phi, &theta);
d447 2
a448 2
      printf("\n%3s:  lng1  =%20.15f   lat1  =%20.15f\n", wcs->cel.prj.code,
         lng1, lat1);
d480 3
d506 1
a506 1
   if (wcs->cel.prj.category == QUADCUBE) {
d517 18
a534 18
      img[0][wcs->lng] = -wcs->cel.prj.w[0];
      img[0][wcs->lat] =  wcs->cel.prj.w[0];
      img[1][wcs->lng] = -wcs->cel.prj.w[0];
      img[1][wcs->lat] =  wcs->cel.prj.w[0]*3.0;
      img[2][wcs->lng] =  wcs->cel.prj.w[0];
      img[2][wcs->lat] =  wcs->cel.prj.w[0]*3.0;
      img[3][wcs->lng] =  wcs->cel.prj.w[0];
      img[3][wcs->lat] = -wcs->cel.prj.w[0]*3.0;
      img[4][wcs->lng] = -wcs->cel.prj.w[0];
      img[4][wcs->lat] = -wcs->cel.prj.w[0]*3.0;
      img[5][wcs->lng] = -wcs->cel.prj.w[0];
      img[5][wcs->lat] =  wcs->cel.prj.w[0];
      img[6][wcs->lng] =  wcs->cel.prj.w[0]*7.0;
      img[6][wcs->lat] =  wcs->cel.prj.w[0];
      img[7][wcs->lng] =  wcs->cel.prj.w[0]*7.0;
      img[7][wcs->lat] = -wcs->cel.prj.w[0];
      img[8][wcs->lng] = -wcs->cel.prj.w[0];
      img[8][wcs->lat] = -wcs->cel.prj.w[0];
d546 1
a546 1
   if (wcs->cel.prj.category == POLYCONIC) {
d554 1
d588 1
a588 1
         if (native.cel.prj.category == QUADCUBE && k > 0) {
d634 1
a634 1
         if (native.cel.prj.category == QUADCUBE && k > 0) {
d757 1
a757 1
   sprintf(text, "%s projection - 15 degree graticule", wcs->cel.prj.code);
d763 1
a763 1
      wcs->cel.ref[0], wcs->cel.ref[1]);
d769 1
a769 1
      wcs->cel.ref[2], wcs->cel.ref[3]);
@


3.6
log
@WCSLIB 3.6: "error status/code/number" is now referred to consistently as the
"status return value"; in error messages, print "ERROR" (in uppercase) -
POSIX standard; removed support for K&R C.
@
text
@d3 2
a4 2
*   WCSLIB 3.6 - an implementation of the FITS WCS convention.
*   Copyright (C) 1995-2004, Mark Calabretta
d6 4
a9 4
*   This program is free software; you can redistribute it and/or modify it
*   under the terms of the GNU General Public License as published by the
*   Free Software Foundation; either version 2 of the License, or (at your
*   option) any later version.
d11 4
a14 4
*   This program is distributed in the hope that it will be useful, but
*   WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*   General Public License for more details.
d17 2
a18 2
*   with this library; if not, write to the Free Software Foundation, Inc.,
*   675 Mass Ave, Cambridge, MA 02139, USA.
d30 1
a30 1
*   $Id: twcs2.c,v 3.5 2004/06/28 01:08:21 mcalabre Exp mcalabre $
@


3.5
log
@WCSLIB 3.5
@
text
@d3 1
a3 1
*   WCSLIB 3.5 - an implementation of the FITS WCS convention.
d30 1
a30 1
*   $Id: twcs2.c,v 3.4 2004/02/11 00:23:05 mcalabre Exp mcalabre $
a47 5
#ifndef __STDC__
#ifndef const
#define const
#endif
#endif
d100 2
a101 2
   /* List error messages. */
   printf("\nList of wcs error codes:\n");
d306 1
a306 1
            printf("%3s(s2x): lng1 =%20.15f  lat1 =%20.15f  error %3d\n",
d333 1
a333 1
            printf("  A: wcsmix error %d, %s.\n", status,
d339 1
a339 1
            printf("  A: wcss2p error %d, %s.\n", status,
d358 1
a358 1
            printf("  B: wcsmix error %d, %s.\n", status,
d364 1
a364 1
            printf("  B: wcss2p error %d, %s.\n", status,
d384 1
a384 1
            printf("  C: wcsmix error %d, %s.\n", status,
d390 1
a390 1
            printf("  C: wcss2p error %d, %s.\n", status,
d409 1
a409 1
            printf("  D: wcsmix error %d, %s.\n", status,
d415 1
a415 1
            printf("  D: wcss2p error %d, %s.\n", status,
d837 1
a837 1
      printf("wcsset error%3d\n", status);
@


3.4
log
@WCSLIB 3.4: set native.lonpole = 180.0 explicitly to stop it defaulting to
zero for the zenithal projections.
@
text
@d3 1
a3 1
*   WCSLIB 3.4 - an implementation of the FITS WCS convention.
d28 3
a37 1
*   $Id: twcs2.c,v 3.3 2003/10/21 08:33:51 mcalabre Exp mcalabre $
@


3.3
log
@WCSLIB 3.3: align the list of error codes; check the error status returned by
wcsset() in parser().
@
text
@d3 2
a4 2
*   WCSLIB 3.3 - an implementation of the FITS WCS convention.
*   Copyright (C) 1995-2003, Mark Calabretta
d35 1
a35 1
*   $Id: twcs2.c,v 3.2 2003/09/09 04:40:16 mcalabre Exp mcalabre $
d560 1
a560 1
   native.lonpole = 999.0;
@


3.2
log
@WCSLIB 3.2: set wcs.flag = -1 to initialize memory management in wcsini();
wcscpy() renamed to wcscopy(); rationalized function return codes and
messages.
@
text
@d3 1
a3 1
*   WCSLIB 3.2 - an implementation of the FITS WCS convention.
d35 1
a35 1
*   $Id: twcs2.c,v 3.1 2003/04/28 04:27:07 mcalabre Exp mcalabre $
d106 1
a106 1
      printf("   %d: %s.\n", j, wcs_errmsg[j]);
d134 2
a135 2
   PV[0].i = 4;			/* Longitude axis at j = 4.    */
   PV[0].m = 1;			/* Parameter number.           */
d138 2
a139 2
   PV[1].i = 4;			/* Longitude axis at j = 4.    */
   PV[1].m = 2;			/* Parameter number.           */
d142 8
a149 8
   /* Set the PVi_m cards for the latitude axes.               */
   PV[2].i = 2;			/* Latitude axis at j = 2.     */
   PV[2].m = 1;			/* Parameter number.           */
   PV[2].value = 0.0;		/* PVi_1 (reset below).        */

   PV[3].i = 2;			/* Latitude axis at j = 2.     */
   PV[3].m = 2;			/* Parameter number.           */
   PV[3].value = 0.0;		/* PVi_2 (reset below).        */
a150 1

d178 1
a178 1
   /* CAR: Cartesian. */
d789 1
a789 1
   int i, j;
d839 3
a841 1
   (void)wcsset(wcs);
@


3.1
log
@WCSLIB 3.1
@
text
@d3 1
a3 1
*   WCSLIB 3.1 - an implementation of the FITS WCS convention.
d35 1
a35 1
*   $Id: twcs2.c,v 3.0 2003/04/01 04:16:39 mcalabre Exp mcalabre $
d104 3
a106 3
   printf("\nList of wcsini error codes:\n");
   for (j = 1; j <= 1 ; j++) {
      printf("   %d: %s.\n", j, wcsini_errmsg[j]);
a108 25
   printf("\nList of wcscpy error codes:\n");
   for (j = 1; j <= 1 ; j++) {
      printf("   %d: %s.\n", j, wcscpy_errmsg[j]);
   }

   printf("\nList of wcsset error codes:\n");
   for (j = 1; j <= 6 ; j++) {
      printf("   %d: %s.\n", j, wcsset_errmsg[j]);
   }

   printf("\nList of wcsp2s error codes:\n");
   for (j = 1; j <= 7 ; j++) {
      printf("   %d: %s.\n", j, wcsp2s_errmsg[j]);
   }

   printf("\nList of wcss2p error codes:\n");
   for (j = 1; j <= 7 ; j++) {
      printf("   %d: %s.\n", j, wcss2p_errmsg[j]);
   }

   printf("\nList of wcsmix error codes:\n");
   for (j = 1; j <= 8 ; j++) {
      printf("   %d: %s.\n", j, wcsmix_errmsg[j]);
   }

d275 1
d338 1
a338 1
                   wcsmix_errmsg[status]);
d344 1
a344 1
                   wcss2p_errmsg[status]);
d363 1
a363 1
                   wcsmix_errmsg[status]);
d369 1
a369 1
                   wcss2p_errmsg[status]);
d389 1
a389 1
                   wcsmix_errmsg[status]);
d395 1
a395 1
                   wcss2p_errmsg[status]);
d414 1
a414 1
                   wcsmix_errmsg[status]);
d420 1
a420 1
                   wcss2p_errmsg[status]);
d558 1
a558 1
   (void)wcscpy(1, wcs, &native);
@


3.0
log
@WCSLIB 3.0
@
text
@d3 1
a3 1
*   WCSLIB 3.0 - an implementation of the FITS WCS convention.
d35 1
a35 1
*   $Id: twcs2.c,v 2.16 2001/09/05 05:07:17 mcalabre Exp $
@


2.18
log
@Updated date in copyright notice.
@
text
@d3 2
a4 2
*   WCSLIB - an implementation of the FITS WCS proposal.
*   Copyright (C) 1995-2002, Mark Calabretta
d22 4
a25 4
*      Postal address: Dr. Mark Calabretta,
*                      Australia Telescope National Facility,
*                      P.O. Box 76,
*                      Epping, NSW, 2121,
d30 2
a31 2
*   twcs2 tests wcsmix() for closure on the 1 degree celestial grid for a
*   number of selected projections.  Points with good solutions are marked
d35 1
a35 1
*   $Id: twcs2.c,v 2.17 2001/09/05 05:07:17 mcalabre Exp mcalabre $
d38 1
d42 3
a44 3
#include <cpgplot.h>
#include "sph.h"
#include "wcs.h"
d52 30
a81 2
/* Set to 1 to skip mixex(), primarily for debugging purposes. */
int skip_mixex = 0;
d83 2
a84 8
char ctype[4][9] = {"FREQ    ", "XLAT-xxx", "TIME    ", "XLON-xxx"};
double crpix[4] =  { 0.0,  0.0,  0.0,  0.0};
double pc[4][4] = {{ 1.1,  0.0,  0.0,  0.0},
                   { 0.0,  1.0,  0.0,  0.1},
                   { 0.0,  0.0,  1.0,  0.0},
                   { 0.0,  0.2,  0.0,  1.0}};
double cdelt[4] =  { 1.0,  1.0,  1.0, -1.0};
double crval[4] =  {408e6, 0.0, -2e3,  0.0};
a88 1
   void grdplt(), mixex();
a90 5
   const double tol = 1.0e-9;
   double latc;
   struct celprm cel0, celc, celp, ntv0, ntvc, ntvp;
   struct prjprm prj;
   struct linprm lin;
d100 2
a101 2
   printf("\nTesting WCSLIB wcsmix routine\n");
   printf("-----------------------------\n");
d104 10
d115 3
a117 1
   printf("   %d: %s.\n", 1, wcsset_errmsg[1]);
d119 3
a121 3
   printf("\nList of wcsfwd error codes:\n");
   for (j = 1; j <=4 ; j++) {
      printf("   %d: %s.\n", j, wcsfwd_errmsg[j]);
d124 3
a126 3
   printf("\nList of wcsrev error codes:\n");
   for (j = 1; j <=4 ; j++) {
      printf("   %d: %s.\n", j, wcsrev_errmsg[j]);
d130 1
a130 1
   for (j = 1; j <=5 ; j++) {
d152 24
a175 54
   lin.flag  = 0;
   lin.naxis = 4;
   lin.crpix = crpix;
   lin.pc    = (double*)pc;
   lin.cdelt = cdelt;

   for (j = 0; j < 10; prj.p[j++] = 0.0);
   for (j = 0; j < 10; prj.w[j++] = 0.0);
   prj.r0 = 0.0;

   /* Latitude midway between the standard parallels for the conics. */
   latc = 60.0;

   /* Set reference angles for native grids; polar projections... */
   ntvp.ref[0]  =   0.0;
   ntvp.ref[1]  =  90.0;
   ntvp.ref[2]  = 999.0;
   ntvp.ref[3]  = 999.0;

   /*  ...conic projections... */
   ntvc.ref[0]  =   0.0;
   ntvc.ref[1]  =  latc;
   ntvc.ref[2]  = 999.0;
   ntvc.ref[3]  = 999.0;

   /* ...cylindrical and conventional projections. */
   ntv0.ref[0]  =   0.0;
   ntv0.ref[1]  =   0.0;
   ntv0.ref[2]  = 999.0;
   ntv0.ref[3]  = 999.0;

   /* Set reference angles for the celestial grids; polar projections... */
   celp.ref[0] = 150.0;
   celp.ref[1] = -30.0;
   celp.ref[2] = 150.0;
   celp.ref[3] = 999.0;

   /* Force celp to be initialized since we want to use it now. */
   celp.flag = 0;
   (void) celset("ARC", &celp, &prj);

   /* Compute reference angles for the cylindrical and conic projections */
   /* so that they all use the same oblique celestial grid regardless of */
   /* the reference point; conic projections... */
   sphrev (0.0, latc, celp.euler, &celc.ref[0], &celc.ref[1]);
   sphfwd (0.0, 90.0, celp.euler, &celc.ref[2], &celc.ref[3]);

   /* ...cylindrical and conventional projections. */
   sphrev (0.0,  0.0, celp.euler, &cel0.ref[0], &cel0.ref[1]);
   sphfwd (0.0, 90.0, celp.euler, &cel0.ref[2], &cel0.ref[3]);

   /* Note that we have 6 contexts (NTVP, NTVC, NTV0, CELP, CELC, and CEL0). */
   /* Routines GRDPLT and MIXEX will each force these to be initialized on */
   /* every invokation since PCODE will differ each time. */
d178 4
a181 5
   strncpy(&ctype[1][5], "ARC", 3);
   strncpy(&ctype[3][5], "ARC", 3);
   grdplt(1, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntvp, &celp,
          &prj, &lin);
   mixex(tol, ctype, crval, &celp, &prj, &lin);
d184 4
a187 5
   strncpy(&ctype[1][5], "ZEA", 3);
   strncpy(&ctype[3][5], "ZEA", 3);
   grdplt(1, -120.0, 120.0, -120.0, 120.0, ctype, crval, &ntvp, &celp,
          &prj, &lin);
   mixex(tol, ctype, crval, &celp, &prj, &lin);
d190 6
a195 7
   strncpy(&ctype[1][5], "CYP", 3);
   strncpy(&ctype[3][5], "CYP", 3);
   prj.p[1] = 3.0;
   prj.p[2] = 0.8;
   grdplt(2, -170.0, 170.0, -170.0, 170.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d198 5
a202 6
   strncpy(&ctype[1][5], "CEA", 3);
   strncpy(&ctype[3][5], "CEA", 3);
   prj.p[1] = 0.75;
   grdplt(2, -200.0, 200.0, -200.0, 200.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d205 4
a208 5
   strncpy(&ctype[1][5], "CAR", 3);
   strncpy(&ctype[3][5], "CAR", 3);
   grdplt(2, -210.0, 210.0, -210.0, 210.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d211 4
a214 5
   strncpy(&ctype[1][5], "SFL", 3);
   strncpy(&ctype[3][5], "SFL", 3);
   grdplt(4, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d217 4
a220 5
   strncpy(&ctype[1][5], "PAR", 3);
   strncpy(&ctype[3][5], "PAR", 3);
   grdplt(4, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d223 4
a226 5
   strncpy(&ctype[1][5], "MOL", 3);
   strncpy(&ctype[3][5], "MOL", 3);
   grdplt(4, -170.0, 170.0, -170.0, 170.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d229 4
a232 5
   strncpy(&ctype[1][5], "AIT", 3);
   strncpy(&ctype[3][5], "AIT", 3);
   grdplt(4, -170.0, 170.0, -170.0, 170.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d235 6
a240 7
   strncpy(&ctype[1][5], "COE", 3);
   strncpy(&ctype[3][5], "COE", 3);
   prj.p[1] = latc;
   prj.p[2] = 15.0;
   grdplt(3, -140.0, 140.0, -120.0, 160.0, ctype, crval, &ntvc, &celc,
          &prj, &lin);
   mixex(tol, ctype, crval, &celc, &prj, &lin);
d243 6
a248 7
   strncpy(&ctype[1][5], "COD", 3);
   strncpy(&ctype[3][5], "COD", 3);
   prj.p[1] = latc;
   prj.p[2] = 15.0;
   grdplt(3, -200.0, 200.0, -180.0, 220.0, ctype, crval, &ntvc, &celc,
          &prj, &lin);
   mixex(tol, ctype, crval, &celc, &prj, &lin);
d251 5
a255 6
   strncpy(&ctype[1][5], "BON", 3);
   strncpy(&ctype[3][5], "BON", 3);
   prj.p[1] = 30.0;
   grdplt(4, -160.0, 160.0, -160.0, 160.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d258 4
a261 5
   strncpy(&ctype[1][5], "PCO", 3);
   strncpy(&ctype[3][5], "PCO", 3);
   grdplt(4, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d264 4
a267 5
   strncpy(&ctype[1][5], "TSC", 3);
   strncpy(&ctype[3][5], "TSC", 3);
   grdplt(5, -340.0, 80.0, -210.0, 210.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d270 4
a273 5
   strncpy(&ctype[1][5], "QSC", 3);
   strncpy(&ctype[3][5], "QSC", 3);
   grdplt(5, -340.0, 90.0, -210.0, 210.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);
d281 216
a496 2
void grdplt(type, imin, imax, jmin, jmax, ctype, crval, native, celest, prj,
   lin)
d498 1
a498 1
int    type;
a499 5
char   ctype[][9];
double crval[];
struct celprm *native, *celest;
struct prjprm *prj;
struct linprm *lin;
d502 2
d505 19
a523 5
   int    ci, ilat, ilng, k;
   float  fimax, fimin, fjmax, fjmin, ir[512], jr[512];
   double lat, lng, phi, theta, img[4], pix[4], world[4];
   double step;
   struct wcsprm wcs;
a524 5
   wcs.flag = 0;
   native->flag = 0;
   celest->flag = 0;
   prj->flag = 0;
   prj->r0 = 0.0;
d533 2
a534 10
   /* Issue a dummy call to initialize data structures. */
   world[0] = crval[0];
   world[1] = crval[1];
   world[2] = crval[2];
   world[3] = crval[3];
   (void) wcsfwd(ctype, &wcs, world, crval, celest, &phi, &theta, prj, img,
                 lin, pix);

   if (type == 5) {
      /* Some sort of quad-cube projection. */
d538 32
a569 58
      img[0] = 0.0;
      img[1] = 0.0;
      img[2] = 0.0;
      img[3] = 0.0;

      img[wcs.lng] = -prj->w[0];
      img[wcs.lat] =  prj->w[0];
      linfwd(img, lin, pix);
      ir[0] = pix[wcs.lng];
      jr[0] = pix[wcs.lat];

      img[wcs.lng] = -prj->w[0];
      img[wcs.lat] =  prj->w[0]*3.0;
      linfwd(img, lin, pix);
      ir[1] = pix[wcs.lng];
      jr[1] = pix[wcs.lat];

      img[wcs.lng] =  prj->w[0];
      img[wcs.lat] =  prj->w[0]*3.0;
      linfwd(img, lin, pix);
      ir[2] = pix[wcs.lng];
      jr[2] = pix[wcs.lat];

      img[wcs.lng] =  prj->w[0];
      img[wcs.lat] = -prj->w[0]*3.0;
      linfwd(img, lin, pix);
      ir[3] = pix[wcs.lng];
      jr[3] = pix[wcs.lat];

      img[wcs.lng] = -prj->w[0];
      img[wcs.lat] = -prj->w[0]*3.0;
      linfwd(img, lin, pix);
      ir[4] = pix[wcs.lng];
      jr[4] = pix[wcs.lat];

      img[wcs.lng] = -prj->w[0];
      img[wcs.lat] =  prj->w[0];
      linfwd(img, lin, pix);
      ir[5] = pix[wcs.lng];
      jr[5] = pix[wcs.lat];

      img[wcs.lng] =  prj->w[0]*7.0;
      img[wcs.lat] =  prj->w[0];
      linfwd(img, lin, pix);
      ir[6] = pix[wcs.lng];
      jr[6] = pix[wcs.lat];

      img[wcs.lng] =  prj->w[0]*7.0;
      img[wcs.lat] = -prj->w[0];
      linfwd(img, lin, pix);
      ir[7] = pix[wcs.lng];
      jr[7] = pix[wcs.lat];

      img[wcs.lng] = -prj->w[0];
      img[wcs.lat] = -prj->w[0];
      linfwd(img, lin, pix);
      ir[8] = pix[wcs.lng];
      jr[8] = pix[wcs.lat];
d574 5
a578 12
   /* Write a descriptive title. */
   cpgsci(1);
   sprintf(text, "%s projection - 15 degree graticule", wcs.pcode);
   printf("\n%s\n", text);
   fjmin = jmin - 10.0;
   cpgtext(fimin, fjmin, text);

   sprintf(text, "centered on celestial coordinates (%6.2f,%6.2f)",
      celest->ref[0], celest->ref[1]);
   printf("%s\n", text);
   fjmin = jmin - 20.0;
   cpgtext(fimin, fjmin, text);
a579 5
   sprintf(text, "with celestial pole at native coordinates (%7.2f,%7.2f)",
      celest->ref[2], celest->ref[3]);
   printf("%s\n", text);
   fjmin = jmin - 30.0;
   cpgtext(fimin, fjmin, text);
d581 6
a587 1
   /* Draw the native coordinate grid faintly in the background. */
a589 6
   if (type == 4) {
      step = 10.0;
   } else {
      step = 15.0;
   }

d596 2
a597 1
      k = 0;
d599 6
a604 1
         lat = (double)ilat;
d606 4
a609 6
         world[wcs.lng] = lng;
         world[wcs.lat] = lat;
         if (wcsfwd(ctype, &wcs, world, crval, native, &phi, &theta, prj, img,
                    lin, pix)) {
            continue;
         }
d611 7
a617 3
         if (type == 5 && k > 0) {
            if (fabs(pix[wcs.lng]-ir[k-1]) > 2.0 ||
                fabs(pix[wcs.lat]-jr[k-1]) > 5.0) {
d623 2
a624 2
         ir[k] = pix[wcs.lng];
         jr[k] = pix[wcs.lat];
d626 3
d638 2
a639 1
      k = 0;
d645 11
a655 6
         world[wcs.lng] = lng;
         world[wcs.lat] = lat;
         if (wcsfwd(ctype, &wcs, world, crval, native, &phi, &theta, prj, img,
                    lin, pix)) {
            continue;
         }
d657 7
a663 3
         if (type == 5 && k > 0) {
            if (fabs(pix[wcs.lng]-ir[k-1]) > 2.0 ||
                fabs(pix[wcs.lat]-jr[k-1]) > 5.0) {
d669 2
a670 2
         ir[k] = pix[wcs.lng];
         jr[k] = pix[wcs.lat];
d672 3
d681 1
a681 1
   /* Draw a colour-coded celestial coordinate grid. */
d691 2
a692 1
      k = 0;
d696 11
a706 6
         world[wcs.lng] = lng;
         world[wcs.lat] = lat;
         if (wcsfwd(ctype, &wcs, world, crval, celest, &phi, &theta, prj, img,
                    lin, pix)) {
            continue;
         }
d708 4
d714 2
a715 2
            if (fabs(pix[wcs.lng]-ir[k-1]) > step ||
                fabs(pix[wcs.lat]-jr[k-1]) > step) {
d721 2
a722 2
         ir[k] = pix[wcs.lng];
         jr[k] = pix[wcs.lat];
d724 3
d740 2
a741 1
      k = 0;
d745 11
a755 6
         world[wcs.lng] = lng;
         world[wcs.lat] = lat;
         if (wcsfwd(ctype, &wcs, world, crval, celest, &phi, &theta, prj, img,
                    lin, pix)) {
            continue;
         }
d757 4
d763 2
a764 2
            if (fabs(pix[wcs.lng]-ir[k-1]) > step ||
                fabs(pix[wcs.lat]-jr[k-1]) > step) {
d770 2
a771 2
         ir[k] = pix[wcs.lng];
         jr[k] = pix[wcs.lat];
d773 3
a780 1
   cpgsci(2);
d782 6
a787 2
   return;
}
d789 5
d795 5
a799 13
/*----------------------------------------------------------------------------
*   mixex() tests wcsmix().
*
*   Given:
*      tol      double   Reporting tolerance, degrees.
*      ctype   char[][9] Coordinate axis types.
*      crval    double[] Coordinate reference values.
*
*   Given and returned:
*      cel      celprm*  Coordinate transformation parameters.
*      prj      prjprm*  Projection parameters.
*      lin      linprm*  Linear transformation parameters.
*---------------------------------------------------------------------------*/
d801 1
a801 1
void mixex(tol, ctype, crval, cel, prj, lin)
a802 6
double tol;
char   ctype[][9];
double crval[];
struct celprm *cel;
struct prjprm *prj;
struct linprm *lin;
d804 2
a805 10
{
   void   id();
   int    err, doid, lat, lng;
   register int k;
   float  ipt[1], jpt[1];
   double lng1, lat1, phi, theta;
   double latspan[2], lngspan[2];
   double img[4], pix1[4], pix2[4], pix3[4], world[4];
   double pixlng, pixlat;
   struct wcsprm wcs;
d807 1
a807 1
   if (skip_mixex) return;
d809 1
a809 4
   wcs.flag = 0;
   cel->flag = 0;
   prj->flag = 0;
   prj->r0 = 0.0;
d811 1
a811 2
   /* Find the projection code. */
   (void) wcsset(lin->naxis, ctype, &wcs);
d813 3
a815 9
   printf("Testing %s; reporting tolerance %5.1g deg.\n", wcs.pcode, tol);

   world[0] = 0.0;
   world[1] = 0.0;
   world[2] = 0.0;
   world[3] = 0.0;

   for (lat = 90; lat >= -90; lat--) {
      lat1 = (double)lat;
d817 6
a822 2
      for (lng = -180; lng <= 180; lng++) {
         lng1 = (double)lng;
a823 8
         world[wcs.lng] = lng1;
         world[wcs.lat] = lat1;
         if (err = wcsfwd(ctype, &wcs, world, crval, cel, &phi, &theta, prj,
                          img, lin, pix1)) {
            printf("%3s: lng1 =%20.15f  lat1 =%20.15f  error %3d\n",
               wcs.pcode, lng1, lat1, err);
            continue;
         }
d825 3
a827 2
         pixlng = pix1[wcs.lng];
         pixlat = pix1[wcs.lat];
d829 3
a831 98
         ipt[0] = pixlng;
         jpt[0] = pixlat;
         cpgpt(1, ipt, jpt, -1);

         lngspan[0] = lng1 - 9.3;
         if (lngspan[0] < -180.0) lngspan[0] = -180.0;
         lngspan[1] = lng1 + 4.1;
         if (lngspan[1] >  180.0) lngspan[1] =  180.0;
         latspan[0] = lat1 - 3.7;
         if (latspan[0] <  -90.0) latspan[0] =  -90.0;
         latspan[1] = lat1 + 7.2;
         if (latspan[1] >   90.0) latspan[1] =   90.0;

         doid = 1;

         pix2[wcs.lng] = pixlng;
         if (err = wcsmix(ctype, &wcs, wcs.lng, 1, latspan, 1.0, 0, world,
               crval, cel, &phi, &theta, prj, img, lin, pix2)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  A: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
         } else if (err = wcsfwd(ctype, &wcs, world, crval, cel,
               &phi, &theta, prj, img, lin, pix3)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  A: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lng]-pixlng) > tol &&
                   (fabs(world[wcs.lat]-lat1)  > tol ||
                    fabs(pix2[wcs.lat]-pixlat) > tol)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  A: (lng2) =%20.15f   lat2  =%20.15f\n", world[wcs.lng],
               world[wcs.lat]);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcs.lng],
               pix2[wcs.lat]);
         }


         pix2[wcs.lat] = pixlat;
         if (err = wcsmix(ctype, &wcs, wcs.lat, 1, latspan, 1.0, 0, world,
               crval, cel, &phi, &theta, prj, img, lin, pix2)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  B: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
         } else if (err = wcsfwd(ctype, &wcs, world, crval, cel, &phi, &theta,
               prj, img, lin, pix3)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  B: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lat]-pixlat) > tol &&
                   (fabs(world[wcs.lat]-lat1)  > tol ||
                    fabs(pix2[wcs.lng]-pixlng) > tol)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  B: (lng2) =%20.15f   lat2  =%20.15f\n", world[wcs.lng],
               world[wcs.lat]);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcs.lng],
               pix2[wcs.lat]);
         }

         world[wcs.lat] = lat1;

         pix2[wcs.lng] = pixlng;
         if (err = wcsmix(ctype, &wcs, wcs.lng, 2, lngspan, 1.0, 0, world,
               crval, cel, &phi, &theta, prj, img, lin, pix2)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  C: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
         } else if (err = wcsfwd(ctype, &wcs, world, crval, cel, &phi, &theta,
               prj, img, lin, pix3)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  C: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lng]-pixlng) > tol &&
                   (fabs(world[wcs.lng]-lng1)  > tol ||
                    fabs(pix2[wcs.lat]-pixlat) > tol)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  C:  lng2  =%20.15f  (lat2) =%20.15f\n", world[wcs.lng],
               world[wcs.lat]);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("       (i2) =%20.15f     j2  =%20.15f\n", pix2[wcs.lng],
               pix2[wcs.lat]);
         }


         pix2[wcs.lat] = pixlat;
         if (err = wcsmix(ctype, &wcs, wcs.lat, 2, lngspan, 1.0, 0, world,
               crval, cel, &phi, &theta, prj, img, lin, pix2)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  D: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
         } else if (err = wcsfwd(ctype, &wcs, world, crval, cel, &phi, &theta,
               prj, img, lin, pix3)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  D: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lat]-pixlat) > tol &&
                   (fabs(world[wcs.lng]-lng1)  > tol ||
                    fabs(pix2[wcs.lng]-pixlng) > tol)) {
            id(&doid, wcs.pcode, cel, lng1, lat1, pixlng, pixlat);
            printf("  D:  lng2  =%20.15f  (lat2) =%20.15f\n", world[wcs.lng],
               world[wcs.lat]);
            printf("       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
            printf("        i2  =%20.15f    (j2) =%20.15f\n", pix2[wcs.lng],
               pix2[wcs.lat]);
         }
d833 4
d840 3
a842 1
   for (k = 0; k < 10; prj->p[k++] = 0.0);
d844 3
a846 2
   return;
}
d848 3
a850 7

void id(doid, pcode, cel, lng1, lat1, pixlng, pixlat)

int    *doid;
char   pcode[4];
struct celprm *cel;
double lng1, lat1, pixlng, pixlat;
d852 2
a853 3
{
   float  ipt[1], jpt[1];
   double phi, theta;
d855 2
a856 3
   if (*doid) {
      /* Compute native coordinates. */
      sphfwd(lng1, lat1, cel->euler, &phi, &theta);
d858 4
a861 4
      printf("\n%3s:  lng1  =%20.15f   lat1  =%20.15f\n", pcode, lng1, lat1);
      printf(  "       phi  =%20.15f  theta  =%20.15f\n", phi, theta);
      printf(  "        i1  =%20.15f     j1  =%20.15f\n", pixlng, pixlat);
      *doid = 0;
d863 2
a864 6
      cpgsci(9);
      ipt[0] = pixlng;
      jpt[0] = pixlat;
      cpgpt(1, ipt, jpt, 21);
      cpgsci(2);
   }
@


2.17
log
@Reordered projections to match paper.
@
text
@d4 1
a4 1
*   Copyright (C) 1995-2001, Mark Calabretta
d35 1
a35 1
*   $Id: twcs2.c,v 2.16 2001/09/05 04:41:01 mcalabre Exp mcalabre $
@


2.16
log
@Augmented the error reports.
@
text
@d35 1
a35 1
*   $Id: twcs2.c,v 2.15 2000/12/04 08:31:18 mcalabre Exp mcalabre $
d201 8
d216 18
a233 5
   /* CEA: cylindrical equal area. */
   strncpy(&ctype[1][5], "CEA", 3);
   strncpy(&ctype[3][5], "CEA", 3);
   prj.p[1] = 0.75;
   grdplt(2, -200.0, 200.0, -200.0, 200.0, ctype, crval, &ntv0, &cel0,
d237 4
a240 6
   /* COD: conic equidistant. */
   strncpy(&ctype[1][5], "COD", 3);
   strncpy(&ctype[3][5], "COD", 3);
   prj.p[1] = latc;
   prj.p[2] = 15.0;
   grdplt(3, -200.0, 200.0, -180.0, 220.0, ctype, crval, &ntvc, &celc,
d242 1
a242 1
   mixex(tol, ctype, crval, &celc, &prj, &lin);
d253 9
d277 4
a280 25
   /* SFL: Sanson-Flamsteed. */
   strncpy(&ctype[1][5], "SFL", 3);
   strncpy(&ctype[3][5], "SFL", 3);
   grdplt(4, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);

   /* PAR: parabolic. */
   strncpy(&ctype[1][5], "PAR", 3);
   strncpy(&ctype[3][5], "PAR", 3);
   grdplt(4, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);

   /* AIT: Hammer-Aitoff. */
   strncpy(&ctype[1][5], "AIT", 3);
   strncpy(&ctype[3][5], "AIT", 3);
   grdplt(4, -170.0, 170.0, -170.0, 170.0, ctype, crval, &ntv0, &cel0,
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);

   /* MOL: Mollweide's projection. */
   strncpy(&ctype[1][5], "MOL", 3);
   strncpy(&ctype[3][5], "MOL", 3);
   grdplt(4, -170.0, 170.0, -170.0, 170.0, ctype, crval, &ntv0, &cel0,
a287 7
          &prj, &lin);
   mixex(tol, ctype, crval, &cel0, &prj, &lin);

   /* TSC: tangential spherical cube. */
   strncpy(&ctype[1][5], "TSC", 3);
   strncpy(&ctype[3][5], "TSC", 3);
   grdplt(5, -340.0, 80.0, -210.0, 210.0, ctype, crval, &ntv0, &cel0,
@


2.15
log
@Use the cpgplot interface to PGPLOT; renamed "GLS" -> "SFL"; eliminated GNU
compiler warnings.
@
text
@d4 1
a4 1
*   Copyright (C) 1995-2000, Mark Calabretta
d35 1
a35 1
*   $Id: twcs2.c,v 2.14 2000/05/10 04:44:05 mcalabre Exp mcalabre $
d677 4
a680 1
            printf("  A: lat2 =%20.15f    j2 =%20.15f\n", world[wcs.lat],
d698 5
a702 2
            printf("  B: lat2 =%20.15f    i2 =%20.15f\n", world[wcs.lat],
               pix2[wcs.lng]);
d720 4
a723 1
            printf("  C: lng2 =%20.15f    j2 =%20.15f\n", world[wcs.lng],
d741 5
a745 2
            printf("  D: lng2 =%20.15f    i2 =%20.15f\n", world[wcs.lng],
               pix2[wcs.lng]);
d772 3
a774 3
      printf("%3s: lng1 =%20.15f  lat1 =%20.15f\n", pcode, lng1, lat1);
      printf("      phi =%20.15f theta =%20.15f\n", phi, theta);
      printf("       i1 =%20.15f    j1 =%20.15f\n", pixlng, pixlat);
@


2.14
log
@Updated date in copyright notice.
@
text
@d35 1
a35 1
*   $Id: twcs2.c,v 2.13 2000/01/31 07:02:47 mcalabre Exp mcalabre $
d41 1
d63 1
a63 1
main()
d108 1
a108 1
   pgbeg(0, text, 1, 1);
d111 10
a120 10
   pgscr(0, 0.00, 0.00, 0.00);
   pgscr(1, 1.00, 1.00, 0.00);
   pgscr(2, 1.00, 1.00, 1.00);
   pgscr(3, 0.50, 0.50, 0.80);
   pgscr(4, 0.80, 0.50, 0.50);
   pgscr(5, 0.80, 0.80, 0.80);
   pgscr(6, 0.50, 0.50, 0.80);
   pgscr(7, 0.80, 0.50, 0.50);
   pgscr(8, 0.30, 0.50, 0.30);
   pgscr(9, 1.00, 0.75, 0.00);
d249 3
a251 3
   /* GLS: Sanson-Flamsteed (global sinusoid). */
   strncpy(&ctype[1][5], "GLS", 3);
   strncpy(&ctype[3][5], "GLS", 3);
d291 1
a291 1
   pgend();
d327 1
a327 1
   pgenv(fimin, fimax, fjmin, fjmax, 1, -2);
d339 1
a339 1
      pgsci(8);
d401 1
a401 1
      pgline(9, ir, jr);
d405 1
a405 1
   pgsci(1);
d408 2
a409 1
   pgtext(imin, jmin-10.0, text);
d411 1
a411 1
   sprintf(text, "centered on celestial coordinates (%6.2lf,%6.2lf)",
d414 2
a415 1
   pgtext(imin, jmin-20.0, text);
d417 1
a417 1
   sprintf(text, "with celestial pole at native coordinates (%7.2lf,%7.2lf)",
d420 2
a421 1
   pgtext(imin, jmin-30.0, text);
d425 1
a425 1
   pgsci(8);
d453 1
a453 1
               if (k > 1) pgline(k, ir, jr);
d463 1
a463 1
      pgline(k, ir, jr);
d486 1
a486 1
               if (k > 1) pgline(k, ir, jr);
d496 1
a496 1
      pgline(k, ir, jr);
d508 1
a508 1
      pgsci(ilng?ci:1);
d525 1
a525 1
               if (k > 1) pgline(k, ir, jr);
d535 1
a535 1
      pgline(k, ir, jr);
d544 1
a544 1
      pgsci(ilat?ci:1);
d561 1
a561 1
               if (k > 1) pgline(k, ir, jr);
d571 1
a571 1
      pgline(k, ir, jr);
d574 1
a574 1
   pgsci(2);
d641 1
a641 1
            printf("%3s: lng1 =%20.15lf  lat1 =%20.15lf  error %3d\n",
d651 1
a651 1
         pgpt(1, ipt, jpt, -1);
d677 1
a677 1
            printf("  A: lat2 =%20.15lf    j2 =%20.15lf\n", world[wcs.lat],
d695 1
a695 1
            printf("  B: lat2 =%20.15lf    i2 =%20.15lf\n", world[wcs.lat],
d714 1
a714 1
            printf("  C: lng2 =%20.15lf    j2 =%20.15lf\n", world[wcs.lng],
d732 1
a732 1
            printf("  D: lng2 =%20.15lf    i2 =%20.15lf\n", world[wcs.lng],
d760 3
a762 3
      printf("%3s: lng1 =%20.15lf  lat1 =%20.15lf\n", pcode, lng1, lat1);
      printf("      phi =%20.15lf theta =%20.15lf\n", phi, theta);
      printf("       i1 =%20.15lf    j1 =%20.15lf\n", pixlng, pixlat);
d765 1
a765 1
      pgsci(9);
d768 2
a769 2
      pgpt(1, ipt, jpt, 21);
      pgsci(2);
@


2.13
log
@Fixed comment concerning use of ieee_handler().
@
text
@d4 1
a4 1
*   Copyright (C) 1995-1999, Mark Calabretta
d35 1
a35 1
*   $Id: twcs2.c,v 2.12 1999/12/13 07:35:38 mcalabre Exp mcalabre $
@


2.12
log
@Revised include file handling; added return statement.
@
text
@d35 1
a35 1
*   $Id: twcs2.c,v 2.11 1999/12/13 03:41:53 mcalabre Exp mcalabre $
d79 1
a79 1
/* call ieee_handler ("set", "common", SIGFPE_ABORT); */
@


2.11
log
@Lowered reporting tolerance to 1e-9 (was 1e-10).
@
text
@d35 1
a35 1
*   $Id: twcs2.c,v 2.10 1999/11/19 01:01:19 mcalabre Exp mcalabre $
d38 1
d40 2
d292 1
a292 1
   exit(0);
@


2.10
log
@"Closure tolerance" becomes "Reporting tolerance"; changed labelling on
error messages from 1,2,3,4 to A,B,C,D to avoid confusion with other numbers.
@
text
@d35 1
a35 1
*   $Id: twcs2.c,v 2.9 1999/06/16 00:13:37 mcalabre Exp mcalabre $
d65 1
a65 1
   const double tol = 1.0e-10;
@


2.9
log
@Updated date in copyright notice.
@
text
@d35 1
a35 1
*   $Id: twcs2.c,v 2.8 1998/02/25 07:05:50 mcalabre Exp mcalabre $
d577 1
a577 1
*      tol      double   Closure tolerance, degrees.
d617 1
a617 1
   printf("Testing %s; closure tolerance %8.1g deg.\n", wcs.pcode, tol);
d661 1
a661 1
            printf("  1: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
d665 4
a668 2
            printf("  1: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lng]-pixlng) > tol) {
d670 1
a670 1
            printf("  1: lat2 =%20.15lf    j2 =%20.15lf\n", world[wcs.lat],
d679 1
a679 1
            printf("  2: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
d683 4
a686 2
            printf("  2: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lat]-pixlat) > tol) {
d688 1
a688 1
            printf("  2: lat2 =%20.15lf    i2 =%20.15lf\n", world[wcs.lat],
d698 1
a698 1
            printf("  3: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
d702 4
a705 2
            printf("  3: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lng]-pixlng) > tol) {
d707 1
a707 1
            printf("  3: lng2 =%20.15lf    j2 =%20.15lf\n", world[wcs.lng],
d716 1
a716 1
            printf("  4: wcsmix error %d, %s.\n", err, wcsmix_errmsg[err]);
d720 4
a723 2
            printf("  4: wcsfwd error %d, %s.\n", err, wcsfwd_errmsg[err]);
         } else if (fabs(pix3[wcs.lat]-pixlat) > tol) {
d725 1
a725 1
            printf("  4: lng2 =%20.15lf    i2 =%20.15lf\n", world[wcs.lng],
@


2.8
log
@Updated date in copyright notice.
@
text
@d4 1
a4 1
*   Copyright (C) 1995-1998, Mark Calabretta
d35 1
a35 1
*   $Id: twcs2.c,v 2.7 1998/02/25 06:37:56 mcalabre Exp mcalabre $
@


2.7
log
@Removed the warning about wcsmix() error 5 (no solution); call wcsmix() with
viter = 0 to cause it to use its default value; tweaked the plot boundary for
COD and COE to prevent truncation.
@
text
@d4 1
a4 1
*   Copyright (C) 1995-1997 Mark Calabretta
d35 1
a35 1
*   $Id: twcs2.c,v 2.6 1998/01/30 00:18:21 mcalabre Exp mcalabre $
@


2.6
log
@Include <stdlib.h>, and replace return from main with exit.
@
text
@d35 1
a35 1
*   $Id: twcs2.c,v 2.5 1996/05/07 20:32:29 mcalabre Exp mcalabre $
a173 6
   printf("\n\nNote: Expect to see a few occurrences of wcsmix error 5 (no ");
   printf("solution) at\n");
   printf("points corresponding to the native poles for those projections ");
   printf("where the\n");
   printf("pole is represented as a finite interval.\n");

d217 1
a217 1
   grdplt(3, -200.0, 200.0, -190.0, 210.0, ctype, crval, &ntvc, &celc,
d226 1
a226 1
   grdplt(3, -140.0, 140.0, -130.0, 150.0, ctype, crval, &ntvc, &celc,
d658 1
a658 1
         if (err = wcsmix(ctype, &wcs, wcs.lng, 1, latspan, 1.0, 2, world,
d674 1
a674 1
         if (err = wcsmix(ctype, &wcs, wcs.lat, 1, latspan, 1.0, 2, world,
d691 1
a691 1
         if (err = wcsmix(ctype, &wcs, wcs.lng, 2, lngspan, 1.0, 2, world,
d707 1
a707 1
         if (err = wcsmix(ctype, &wcs, wcs.lat, 2, lngspan, 1.0, 2, world,
@


2.5
log
@Name changed from twcs to twcs2.  Print and use predefined error messages.
@
text
@d4 1
a4 1
*   Copyright (C) 1995,1996 Mark Calabretta
d35 1
a35 1
*   $Id: twcs.c,v 2.4 1995/11/16 06:19:31 mcalabre Exp mcalabre $
d295 1
a295 1
   return 0;
@


2.4
log
@Tweaked the sizes of the PGPLOT viewports to avoid truncation.
@
text
@d4 1
a4 1
*   Copyright (C) 1995, Mark Calabretta
d30 1
a30 1
*   twcs tests wcsmix() for closure on the 1 degree celestial grid for a
d35 1
a35 1
*   $Id: twcs.c,v 2.3 1995/11/16 04:50:43 mcalabre Exp mcalabre $
d47 2
d78 24
d174 1
a174 2
   printf("\nTesting wcs.\n");
   printf("Note: Expect to see a few occurrences of wcsmix error 5 (no ");
d178 1
a178 1
   printf("pole is represented as a finite interval.\n\n");
d223 1
a223 1
   grdplt(3, -200.0, 200.0, -200.0, 200.0, ctype, crval, &ntvc, &celc,
d232 1
a232 1
   grdplt(3, -140.0, 140.0, -140.0, 140.0, ctype, crval, &ntvc, &celc,
d409 1
a409 1
   printf("%s\n", text);
d613 2
d667 2
a668 2
            printf("  1: wcsmix error %d\n", err);
         } else if (err = wcsfwd(ctype, &wcs, world, crval, cel, 
d671 1
a671 1
            printf("  1: wcsfwd error %d\n", err);
d683 1
a683 1
            printf("  2: wcsmix error %d\n", err);
d687 1
a687 1
            printf("  2: wcsfwd error %d\n", err);
d700 1
a700 1
            printf("  3: wcsmix error %d\n", err);
d704 1
a704 1
            printf("  3: wcsfwd error %d\n", err);
d716 1
a716 1
            printf("  4: wcsmix error %d\n", err);
d720 1
a720 1
            printf("  4: wcsfwd error %d\n", err);
@


2.3
log
@Changed to use the generalized WCS driver routines.
@
text
@d35 1
a35 1
*   $Id: twcs.c,v 2.2 1995/11/09 03:23:16 mcalabre Exp mcalabre $
d174 1
a174 1
   grdplt(2, -160.0, 160.0, -160.0, 160.0, ctype, crval, &ntv0, &cel0,
d181 1
a181 1
   grdplt(2, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntv0, &cel0,
d189 1
a189 1
   grdplt(2, -195.0, 195.0, -195.0, 195.0, ctype, crval, &ntv0, &cel0,
d198 1
a198 1
   grdplt(3, -190.0, 190.0, -190.0, 190.0, ctype, crval, &ntvc, &celc,
d215 1
a215 1
   grdplt(4, -150.0, 150.0, -150.0, 150.0, ctype, crval, &ntv0, &cel0,
d243 1
a243 1
   grdplt(4, -165.0, 165.0, -165.0, 165.0, ctype, crval, &ntv0, &cel0,
d250 1
a250 1
   grdplt(4, -165.0, 165.0, -165.0, 165.0, ctype, crval, &ntv0, &cel0,
d257 1
a257 1
   grdplt(5, -335.0, 65.0, -180.0, 180.0, ctype, crval, &ntv0, &cel0,
d264 1
a264 1
   grdplt(5, -335.0, 65.0, -180.0, 180.0, ctype, crval, &ntv0, &cel0,
@


2.2
log
@Changed the PC matrix slightly, adding more non-zero off-diagonal elements.
Changed the message about wcsmix error 4 to error 5.
@
text
@d35 1
a35 1
*   $Id: twcs.c,v 2.1 1995/09/12 07:02:15 mcalabre Exp mcalabre $
d48 1
d50 6
a55 5
double pc[4][4] = {{ 1.1,  0.1,  .02,  .01},
                   { 0.2,  1.0,  .01,  .01},
                   { .05,  .03,  1.0,  0.0},
                   { .01,  .04,  .03,  1.0}};
double cdelt[4] =  {-1.0,  1.0,  1.0,  1.0};
d156 5
a160 2
   grdplt("ARC", 1, -190.0, 190.0, -190.0, 190.0, &ntvp, &celp, &prj, &lin);
   mixex("ARC", tol, &celp, &prj, &lin);
d163 5
a167 2
   grdplt("ZEA", 1, -120.0, 120.0, -120.0, 120.0, &ntvp, &celp, &prj, &lin);
   mixex("ZEA", tol, &celp, &prj, &lin);
d170 2
d174 3
a176 2
   grdplt("CYP", 2, -160.0, 160.0, -160.0, 160.0, &ntv0, &cel0, &prj, &lin);
   mixex("CYP", tol, &cel0, &prj, &lin);
d179 5
a183 2
   grdplt("CAR", 2, -190.0, 190.0, -190.0, 190.0, &ntv0, &cel0, &prj, &lin);
   mixex("CAR", tol, &cel0, &prj, &lin);
d186 2
d189 3
a191 2
   grdplt("CEA", 2, -195.0, 195.0, -195.0, 195.0, &ntv0, &cel0, &prj, &lin);
   mixex("CEA", tol, &cel0, &prj, &lin);
d194 2
d198 3
a200 2
   grdplt("COD", 3, -190.0, 190.0, -190.0, 190.0, &ntvc, &celc, &prj, &lin);
   mixex("COD", tol, &celc, &prj, &lin);
d203 2
d207 3
a209 2
   grdplt("COE", 3, -140.0, 140.0, -140.0, 140.0, &ntvc, &celc, &prj, &lin);
   mixex("COE", tol, &celc, &prj, &lin);
d212 2
d215 3
a217 2
   grdplt("BON", 4, -150.0, 150.0, -150.0, 150.0, &ntv0, &cel0, &prj, &lin);
   mixex("BON", tol, &cel0, &prj, &lin);
d220 5
a224 2
   grdplt("PCO", 4, -190.0, 190.0, -190.0, 190.0, &ntv0, &cel0, &prj, &lin);
   mixex("PCO", tol, &cel0, &prj, &lin);
d227 5
a231 2
   grdplt("GLS", 4, -190.0, 190.0, -190.0, 190.0, &ntv0, &cel0, &prj, &lin);
   mixex("GLS", tol, &cel0, &prj, &lin);
d234 5
a238 2
   grdplt("PAR", 4, -190.0, 190.0, -190.0, 190.0, &ntv0, &cel0, &prj, &lin);
   mixex("PAR", tol, &cel0, &prj, &lin);
d241 5
a245 2
   grdplt("AIT", 4, -165.0, 165.0, -165.0, 165.0, &ntv0, &cel0, &prj, &lin);
   mixex("AIT", tol, &cel0, &prj, &lin);
d248 5
a252 2
   grdplt("MOL", 4, -165.0, 165.0, -165.0, 165.0, &ntv0, &cel0, &prj, &lin);
   mixex("MOL", tol, &cel0, &prj, &lin);
d255 5
a259 2
   grdplt("QSC", 5, -335.0, 65.0, -180.0, 180.0, &ntv0, &cel0, &prj, &lin);
   mixex("QSC", tol, &cel0, &prj, &lin);
d262 5
a266 2
   grdplt("TSC", 5, -335.0, 65.0, -180.0, 180.0, &ntv0, &cel0, &prj, &lin);
   mixex("TSC", tol, &cel0, &prj, &lin);
d274 2
a275 1
void grdplt(pcode, type, imin, imax, jmin, jmax, native, celest, prj, lin)
a276 1
char   pcode[4];
d279 3
a281 1
struct celprm *celest, *native;
d289 1
a289 1
   double lat, lng, phi, theta, img[4], pix[4], x, y;
d291 1
d293 1
d307 6
a312 1
   (void) celfwd(pcode, 0.0, 0.0, celest, &phi, &theta, prj, &x, &y);
d319 2
a320 2
      img[0] = -prj->w[0];
      img[1] =  prj->w[0];
d323 3
d327 2
a328 2
      ir[0] = pix[0];
      jr[0] = pix[1];
d330 2
a331 2
      img[0] = -prj->w[0];
      img[1] =  prj->w[0]*3.0;
d333 2
a334 2
      ir[1] = pix[0];
      jr[1] = pix[1];
d336 2
a337 2
      img[0] =  prj->w[0];
      img[1] =  prj->w[0]*3.0;
d339 2
a340 2
      ir[2] = pix[0];
      jr[2] = pix[1];
d342 2
a343 2
      img[0] =  prj->w[0];
      img[1] = -prj->w[0]*3.0;
d345 2
a346 2
      ir[3] = pix[0];
      jr[3] = pix[1];
d348 2
a349 2
      img[0] = -prj->w[0];
      img[1] = -prj->w[0]*3.0;
d351 2
a352 2
      ir[4] = pix[0];
      jr[4] = pix[1];
d354 2
a355 2
      img[0] = -prj->w[0];
      img[1] =  prj->w[0];
d357 2
a358 2
      ir[5] = pix[0];
      jr[5] = pix[1];
d360 2
a361 2
      img[0] =  prj->w[0]*7.0;
      img[1] =  prj->w[0];
d363 2
a364 2
      ir[6] = pix[0];
      jr[6] = pix[1];
d366 2
a367 2
      img[0] =  prj->w[0]*7.0;
      img[1] = -prj->w[0];
d369 2
a370 2
      ir[7] = pix[0];
      jr[7] = pix[1];
d372 2
a373 2
      img[0] = -prj->w[0];
      img[1] = -prj->w[0];
d375 2
a376 2
      ir[8] = pix[0];
      jr[8] = pix[1];
d383 1
a383 1
   sprintf(text, "%s projection - 15 degree graticule", pcode);
d417 4
a420 2
         if (wcsfwd(pcode, lng, lat, native, &phi, &theta, prj, img, lin,
                    pix)) {
d425 2
a426 1
            if (fabs(pix[0]-ir[k-1]) > 2.0 || fabs(pix[1]-jr[k-1]) > 5.0) {
d432 2
a433 2
         ir[k] = pix[0];
         jr[k] = pix[1];
d450 4
a453 2
         if (wcsfwd(pcode, lng, lat, native, &phi, &theta, prj, img, lin,
                    pix)) {
d458 2
a459 1
            if (fabs(pix[0]-ir[k-1]) > 2.0 || fabs(pix[1]-jr[k-1]) > 5.0) {
d465 2
a466 2
         ir[k] = pix[0];
         jr[k] = pix[1];
d488 4
a491 2
         if (wcsfwd(pcode, lng, lat, celest, &phi, &theta, prj, img, lin,
                    pix)) {
d497 2
a498 1
            if (fabs(pix[0]-ir[k-1]) > step || fabs(pix[1]-jr[k-1]) > step) {
d504 2
a505 2
         ir[k] = pix[0];
         jr[k] = pix[1];
d524 4
a527 2
         if (wcsfwd(pcode, lng, lat, celest, &phi, &theta, prj, img, lin,
                    pix)) {
d533 2
a534 1
            if (fabs(pix[0]-ir[k-1]) > step || fabs(pix[1]-jr[k-1]) > step) {
d540 2
a541 2
         ir[k] = pix[0];
         jr[k] = pix[1];
d555 1
a555 1
*   mixex() tests wcs().
a557 1
*      pcode[4] char     Projection code.
d559 2
d568 1
a568 1
void mixex(pcode, tol, cel, prj, lin)
a569 1
char   pcode[4];
d571 2
d582 1
a582 1
   double lng1, lng2, lat1, lat2, phi, theta;
d584 3
a586 1
   double img[4], pix1[4], pix2[4], pix3[4];
d588 1
a588 2
   printf("Testing %s; closure tolerance %8.1g deg.\n", pcode, tol);

d593 10
d609 4
a612 2
         if (err = wcsfwd(pcode, lng1, lat1, cel, &phi, &theta, prj, img,
                          lin, pix1)) {
d614 1
a614 1
               pcode, lng1, lat1, err);
d618 5
a622 2
         ipt[0] = pix1[0];
         jpt[0] = pix1[1];
d636 6
a641 6
         pix2[0] = pix1[0];
         if (err = wcsmix(pcode, -1, latspan, 1.0, 2, &lng1, &lat2, cel,
               &phi, &theta, prj, img, lin, pix2)) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf(" -1: wcsmix error %d\n", err);
         } else if (err = wcsfwd(pcode, lng1, lat2, cel, 
d643 6
a648 5
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf(" -1: wcsfwd error %d\n", err);
         } else if (fabs(pix3[0]-pix1[0]) > tol) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf(" -1: lat2 =%20.15lf    j2 =%20.15lf\n", lat2, pix2[1]);
d652 30
a681 27
         pix2[1] = pix1[1];
         if (err = wcsmix(pcode, -2, latspan, 1.0, 2, &lng1, &lat2, cel,
               &phi, &theta,  prj, img, lin, pix2)) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf(" -2: wcsmix error %d\n", err);
         } else if (err = wcsfwd(pcode, lng1, lat2, cel, &phi, &theta, prj,
               img, lin, pix3)) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf(" -2: wcsfwd error %d\n", err);
         } else if (fabs(pix3[1]-pix1[1]) > tol) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf(" -2: lat2 =%20.15lf    i2 =%20.15lf\n", lat2, pix2[0]);
         }


         pix2[0] = pix1[0];
         if (err = wcsmix(pcode, 1, lngspan, 1.0, 2, &lng2, &lat1, cel,
               &phi, &theta, prj, img, lin, pix2)) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf("  1: wcsmix error %d\n", err);
         } else if (err = wcsfwd(pcode, lng2, lat1, cel, &phi, &theta, prj,
               img, lin, pix3)) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf("  1: wcsfwd error %d\n", err);
         } else if (fabs(pix3[0]-pix1[0]) > tol) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf("  1: lng2 =%20.15lf    j2 =%20.15lf\n", lng2, pix2[1]);
d685 13
a697 12
         pix2[1] = pix1[1];
         if (err = wcsmix(pcode, 2, lngspan, 1.0, 2, &lng2, &lat1, cel,
               &phi, &theta, prj, img, lin, pix2)) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf("  2: wcsmix error %d\n", err);
         } else if (err = wcsfwd(pcode, lng2, lat1, cel, &phi, &theta, prj,
               img, lin, pix3)) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf("  2: wcsfwd error %d\n", err);
         } else if (fabs(pix3[1]-pix1[1]) > tol) {
            id(&doid, pcode, cel, lng1, lat1, pix1);
            printf("  2: lng2 =%20.15lf    i2 =%20.15lf\n", lng2, pix2[0]);
d709 1
a709 1
void id(doid, pcode, cel, lng1, lat1, pix1)
d714 1
a714 1
double lng1, lat1, pix1[2];
d726 1
a726 1
      printf("       i1 =%20.15lf    j1 =%20.15lf\n", pix1[0], pix1[1]);
d730 2
a731 2
      ipt[0] = pix1[0];
      jpt[0] = pix1[1];
@


2.1
log
@Initial revision
@
text
@d35 1
a35 1
*   $Id$
d49 4
a52 4
double pc[4][4] = {{ 1.1,  0.1,  0.0,  0.0},
                   { 0.2,  1.0,  0.0,  0.0},
                   { 0.0,  0.0,  1.0,  0.0},
                   { 0.0,  0.0,  0.0,  1.0}};
d147 5
a151 5
   printf("Note: Expect to see a few occurrences of wcsmix error 4 (no ");
   printf("solution) at points\n");
   printf("corresponding to the native poles for those projections where ");
   printf("the pole is\n");
   printf("represented as a finite interval.\n\n");
@
