Compare commits
	
		
			No commits in common. "da712b0e77d459257c3c3e2d0c369e474628e388" and "623b939df194eeeed34feba1a4e7d1e74404cdf7" have entirely different histories.
		
	
	
		
			da712b0e77
			...
			623b939df1
		
	
		
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,7 +1,3 @@ | ||||
| # Vim stuff | ||||
| *.swp | ||||
| *.swo | ||||
| 
 | ||||
| composer.lock | ||||
| vendor/ | ||||
| docs/ | ||||
|  | ||||
| @ -72,10 +72,8 @@ echo $blob->bitpix->type(); //int32 | ||||
| 
 | ||||
| ## TODO | ||||
| 
 | ||||
| - [x] Read keywords from the FITS header | ||||
| - [x] Separate the main data table (actual image data) from the header (partly done? Who knows...) | ||||
| - [x] Read keywords from the FITS header (but consider values and comments could be more than 80-bytes long) | ||||
| - [ ] History keywords? | ||||
| - [ ] FITS extensions? What to do with NAXIS > 2? | ||||
| - [ ] Actually display the image in the standard output (with SVG?) | ||||
| - [ ]  Actually display the image in the standard output | ||||
| - [ ]  Save the image to PNG and JPG | ||||
| - [ ]  Manipulate the bits using basic processing algorithms?? | ||||
|  | ||||
| @ -13,8 +13,7 @@ | ||||
|         "phpunit/phpunit": "^11.3" | ||||
|     }, | ||||
|     "scripts": { | ||||
|         "run-pstan": "vendor/bin/phpstan analyze src/ --level 6", | ||||
|         "run-tests": "vendor/bin/phpunit tests/ --display-warnings" | ||||
|         "run-pstan": "vendor/bin/phpstan analyze src/ --level 6" | ||||
|     }, | ||||
|     "license": "MIT", | ||||
|     "autoload": { | ||||
|  | ||||
| @ -28,8 +28,6 @@ class FitsHeader | ||||
|     *  | ||||
|     * From the spec: each keyword record, including | ||||
|     * any comments, is at most 80 bytes long | ||||
|     * @todo Comments and keyword values could span more | ||||
|             than one 80-bytes block... | ||||
|     * @return Keyword[] | ||||
|     */ | ||||
|     private function readKeywords(): array | ||||
| @ -52,11 +50,6 @@ class FitsHeader | ||||
|             $name = $keyVal[0]; | ||||
|             $value = $keyVal[1] ?? ''; | ||||
| 
 | ||||
|             if (str_starts_with($name, 'COMMENT')) { | ||||
|                 $value = explode('COMMENT', $name)[1]; | ||||
|                 $name = 'COMMENT'; | ||||
|             } | ||||
| 
 | ||||
|             $keywords[] = new Keyword( | ||||
|                 name : $name, | ||||
|                 value : $value, | ||||
|  | ||||
| @ -6,54 +6,19 @@ use PHPUnit\Framework\TestCase; | ||||
| 
 | ||||
| final class FitsHeaderTest extends TestCase | ||||
| { | ||||
|     private Dumbastro\FitsPhp\Fits $fits; | ||||
|     private Dumbastro\FitsPhp\FitsHeader $header; | ||||
|      | ||||
|     protected function setUp(): void | ||||
|     public function testKeywordValue(): void | ||||
|     { | ||||
|         $this->fits = new Dumbastro\FitsPhp\Fits(__DIR__ . '/test_orion.fit'); | ||||
|         $this->header = new Dumbastro\FitsPhp\FitsHeader($this->fits->headerBlock); | ||||
|     } | ||||
|         $fits = new Dumbastro\FitsPhp\Fits(__DIR__ . '/test_orion.fit'); | ||||
|         $header = new Dumbastro\FitsPhp\FitsHeader($fits->headerBlock); | ||||
| 
 | ||||
|     public function testKeywordValues(): void | ||||
|     { | ||||
|         $this->assertSame( | ||||
|             trim($this->header->getKeywordValue('BITPIX')), | ||||
|             trim($header->getKeywordValue('BITPIX')), | ||||
|             '16' | ||||
|         ); | ||||
|         $this->assertSame( | ||||
|             trim($this->header->getKeywordValue('NAXIS')), | ||||
|             trim($header->getKeywordValue('NAXIS')), | ||||
|             '3' | ||||
|         ); | ||||
|         $this->assertSame( | ||||
|             trim($this->header->getKeywordValue('STACKCNT')), | ||||
|             '86' | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     public function testKeyword(): void | ||||
|     { | ||||
|         $keyword = $this->header->keyword('NAXIS1'); | ||||
| 
 | ||||
|         // Probably useless... (covered by PHPStan)
 | ||||
|         $this->assertInstanceOf(Dumbastro\FitsPhp\Keyword::class, $keyword); | ||||
| 
 | ||||
|         $this->assertEquals($keyword->value, 2448); | ||||
| 
 | ||||
|         $keyword = $this->header->keyword('EQUINOX'); | ||||
| 
 | ||||
|         $this->assertEquals(trim($keyword->value), '2000.'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|     * @todo This fails for COMMENT keywords | ||||
|     public function testToString(): void | ||||
|     { | ||||
|         $headerBlock = $this->fits->headerBlock; | ||||
|         $headerString = $this->header->toString(); | ||||
| 
 | ||||
|         $this->assertEquals($headerBlock, $headerString); | ||||
|     } | ||||
|     */ | ||||
| } | ||||
|   | ||||
|  | ||||
| @ -1,33 +0,0 @@ | ||||
| <?php | ||||
| 
 | ||||
| declare(strict_types=1); | ||||
| 
 | ||||
| use PHPUnit\Framework\TestCase; | ||||
| 
 | ||||
| final class ImageBlobTest extends TestCase | ||||
| { | ||||
|     private Dumbastro\FitsPhp\ImageBlob $imageBlob; | ||||
|     private Dumbastro\FitsPhp\Fits $fits; | ||||
|     private Dumbastro\FitsPhp\FitsHeader $header; | ||||
| 
 | ||||
|     protected function setUp(): void | ||||
|     { | ||||
|         $this->fits = new Dumbastro\FitsPhp\Fits(__DIR__ . '/test_orion.fit'); | ||||
|         $this->header = $this->fits->header(); | ||||
|         $blob = $this->fits->imageBlob; | ||||
| 
 | ||||
|         $this->imageBlob = new Dumbastro\FitsPhp\ImageBlob($this->header, $blob); | ||||
|     } | ||||
| 
 | ||||
|     public function testBitpixValue(): void | ||||
|     { | ||||
|         $this->assertSame($this->imageBlob->bitpix->value, 16); | ||||
|     } | ||||
| 
 | ||||
|     public function testDataBitsLength(): void | ||||
|     { | ||||
|         $this->assertSame($this->imageBlob->dataBits, 16*2448*1669); | ||||
|     } | ||||
| } | ||||
|   | ||||
| 
 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user