RononDex / FitsLibrary

A native C# dotnet core implenetation to read and write astronomical .FITS files following newest specifications
Mozilla Public License 2.0
12 stars 0 forks source link

Is this project still alive? #16

Closed electro-logic closed 3 months ago

electro-logic commented 6 months ago

Hello, Is this project still alive? Would be great to have write support for .fits file Cheers

RononDex commented 6 months ago

Hi @electro-logic

Yes the project is still alive, although my time to work on this project has been very limited the past few months. This might change in the next few weeks though :)

Writing support should be quite straight forward to implement, however, this will not include support for Extension headers at first, as those seem to be a bit more complicated.

There is another (slower, much much older (pre dotnet core)) C# library for fits files that might also work for you until then.

Also the project is open source, if you have some free time contributions are welcome :)

electro-logic commented 6 months ago

Hello,

A basic implementation able to write pixels would be great.

The main issue with other libraries I tried is that they miss basic examples or they are too low level and getting started with them require too much effort (they are discontinued too).

RononDex commented 6 months ago

Yes, writing simple pixel level data should be quite easy, might be able to do something in the next few weeks

electro-logic commented 5 months ago

Hello,

Thanks for working again on the project, is the development branch already working for some testing?

Thanks

RononDex commented 5 months ago

Hi @electro-logic

Sorry no, all it can do at the moment is very basic serialization of the header. I am still working on it but got very limited time due to IRL stuff at the moment

electro-logic commented 5 months ago

Would be great (when you have time) if the next feature is pixel writing in the simplest format (ex. RAW8 / Mono). I can try to add other formats from there (ex. RAW16, BGR, etc..) to help the project

RononDex commented 5 months ago

Actually the formats are really easy to add, I would add them all at once.

The most complicated / time consuming part is correctly writing the header information (without which the fits file is invalid). The content part (the raw data) is really easy to implement.

I have already started working on the header part though

electro-logic commented 4 months ago

Hi, thanks for working on this, Are you planning some high-level API too? For example I'm not interested into .FITS format details, but I would like a method to write pixels and another to write basic metadata (ex. Shutter Time, Gain, etc..). This would help to write some generic code that can save images in multiple formats (ex. .tiff, .fits, etc..)

RononDex commented 4 months ago

Not really no sorry, I don't have the time or interest to implement something like that for now

electro-logic commented 4 months ago

Don't worry, after the write support is done please let me know, I can implement some high-level API and create a pull request for the project

RononDex commented 4 months ago

Thanks, found some time this week to work on it, it is coming along :)

Also, the scope of this repository is "only" handling of fits files, if you want to add a "meta" logic around it, feel free to create another repository where you reference this one and all the other packages you would manage

RononDex commented 4 months ago

Just a quick dev update: I have been able to get a lot done in the past 1-2 weeks (check the development branch). Had to do major refactoring in order to parse multiple HDU's (Header Data Units).

Writing of files (just the image data, no table extensions yet) is done around ~70-80%, mostly missing tests and documentation now and a public API to write the files.

Also, this refactoring made the library (at least the reading part) much much faster than before.

electro-logic commented 4 months ago

Hello, thanks for the update. Very good progress! At some point in future you could do a benchmark with other common Fits libraries and send that to NASA or SpaceX.

RononDex commented 4 months ago

Actually it already contains a benchmark comparing it to the CSharpFits library (old library based on .Net Framework 2.0 I think) and mine is ~twice as fast while reading :P

RononDex commented 3 months ago

Just released the new nuget package 0.4.0-pre with fits writing support :)

You can find the instructions in the Readme. Note there were a few API changes compared to the last version and it runs on .net8.0 now (latest LTS release)

electro-logic commented 3 months ago

Thanks a lot for the release, I'll try it as soon as possible

electro-logic commented 3 months ago

Hello,

Let's say I want to create a FIT file with a monochrome 16 bit image that is 4x1.

The following code seems working fine

            var writer = new FitsDocumentWriter();
            var doc = new FitsDocument<Int16>(new int[] { 4, 1 });
            doc.PrimaryHdu.Data.SetValueAt(10000, new int[] { 0, 0 });
            doc.PrimaryHdu.Data.SetValueAt(20000, new int[] { 1, 0 });
            doc.PrimaryHdu.Data.SetValueAt(25000, new int[] { 2,0 });
            doc.PrimaryHdu.Data.SetValueAt(30000, new int[] { 3,0 });
            await writer.WriteAsync(doc, "sample.fits");

Very good!

RononDex commented 3 months ago

Thanks for testing, and just realized I should probably make the documentation a bit more thorough. Happy you already figured out by yourself how to use it :)

electro-logic commented 3 months ago

Thanks again, the app AstroCapture is now compatible with FITS