Compare commits
2 Commits
623b939df1
...
da712b0e77
Author | SHA1 | Date | |
---|---|---|---|
da712b0e77 | |||
109ae71059 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,7 @@
|
||||
# Vim stuff
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
composer.lock
|
||||
vendor/
|
||||
docs/
|
||||
|
@ -72,8 +72,10 @@ 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...)
|
||||
- [ ] Actually display the image in the standard output
|
||||
- [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?)
|
||||
- [ ] Save the image to PNG and JPG
|
||||
- [ ] Manipulate the bits using basic processing algorithms??
|
||||
|
@ -13,7 +13,8 @@
|
||||
"phpunit/phpunit": "^11.3"
|
||||
},
|
||||
"scripts": {
|
||||
"run-pstan": "vendor/bin/phpstan analyze src/ --level 6"
|
||||
"run-pstan": "vendor/bin/phpstan analyze src/ --level 6",
|
||||
"run-tests": "vendor/bin/phpunit tests/ --display-warnings"
|
||||
},
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
|
@ -28,6 +28,8 @@ 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
|
||||
@ -50,6 +52,11 @@ 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,19 +6,54 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class FitsHeaderTest extends TestCase
|
||||
{
|
||||
public function testKeywordValue(): void
|
||||
{
|
||||
$fits = new Dumbastro\FitsPhp\Fits(__DIR__ . '/test_orion.fit');
|
||||
$header = new Dumbastro\FitsPhp\FitsHeader($fits->headerBlock);
|
||||
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 = new Dumbastro\FitsPhp\FitsHeader($this->fits->headerBlock);
|
||||
}
|
||||
|
||||
public function testKeywordValues(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
trim($header->getKeywordValue('BITPIX')),
|
||||
trim($this->header->getKeywordValue('BITPIX')),
|
||||
'16'
|
||||
);
|
||||
$this->assertSame(
|
||||
trim($header->getKeywordValue('NAXIS')),
|
||||
trim($this->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);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
33
tests/ImageBlobTest.php
Normal file
33
tests/ImageBlobTest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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