Weeks 9 & 10: Slicing, Profiles and a New Factory
Slicing, Profiles and a New Factory π
The last two weeks have been a pretty interesting mix of working on spectrogram slicing and starting to look at one of the bigger architectural changes in radiospectra.
A lot of the work this time was about understanding how the different pieces fit together and figuring out how to make things easier for users and contributors.
Exploring Slicing and Profiles π
After the ndcube refactor, I started looking more closely at how users could work with individual parts of a spectrogram.
One thing I wanted to make easier was getting a time profile at a particular frequency or a frequency profile at a particular time.
Initially, I worked on adding time_profile() and line_profile() methods to GenericSpectrogram.
To make this work, I had to deal with something I hadn't worked with much before—converting physical coordinates into the actual array indices behind the spectrogram.
I added a couple of internal helpers to handle this conversion, so users could provide things like an astropy.time.Time or a frequency with units without having to figure out the corresponding array index themselves.
I also added tests to make sure these conversions work correctly across different cases.
This was a nice learning experience for me because it made me look much more closely at how the WCS and the actual data array are connected.
Starting the SpectrogramFactory Migration π§
The other major thing I've been working on is the SpectrogramFactory migration.
This is definitely one of the bigger changes I've worked on so far.
The existing factory would basically parse the entire file first and create the data and metadata before checking which instrument the file belonged to.
That means quite a lot of work could happen before we even knew which instrument was supposed to handle the file.
The idea behind the new approach is to keep this much lighter.
Instead of fully parsing the file first, the factory can get the basic information needed to identify the instrument. Once the correct instrument is found, that instrument can handle the actual parsing through a new from_raw() method.
So the basic idea becomes:
Old:
Read everything → Identify instrument → Create spectrogram
New:
Read basic information → Identify instrument → Let the instrument parse the data
I've started implementing this approach and have migrated the first two sources:
- WAVES
- e-CALLISTO
There's still a lot to migrate, but getting these two working has given me a much better idea of how the rest of the factory can be moved over.
What's Next? π
For the next couple of weeks, I'll be working through the feedback on the slicing and profiling work and continuing the SpectrogramFactory migration.
There are still several instruments to move to the new from_raw() pattern, so I'm looking forward to seeing how the factory looks once the migration is complete.
It's been really interesting moving from smaller API improvements to working on the bigger architecture of radiospectra, and I'm excited to keep going!
Until next time! π
Comments
Post a Comment