cassidymwagner / fluidsf

FluidSF is a package used to calculate structure functions from fluid data.
https://cassidymwagner.github.io/fluidsf
MIT License
5 stars 3 forks source link

Speedup for rolling functionality, support for uneven/latlon grids, testing/CI, and small changes #4

Closed cassidymwagner closed 8 months ago

cassidymwagner commented 8 months ago

Major changes:

  1. Speed-up from numpy.roll numpy.roll is relatively slow since it makes copies of the original array, so the rolling (or padding) functionality is now handled iteratively with indexing to shift the array with or without replacement, depending on the boundary conditions. The example below is the case for periodic boundary conditions.

    for i in range(10): 
        xroll[:i] = x[-i:]
        xroll[i:] = x[:-i]
        adv_E_roll[:, :i] = adv_E[:, -i:]
        adv_E_roll[:, i:] = adv_E[:, :-i]
  2. Support for more grid types (rectangular, uneven spacing, latitude-longitude)

    • This support is primarily handled through function arguments.
    • Rectangular grids will result in binned structure functions and separation distances for the zonal direction only
      • Number of bins can be set as a function argument
    • In the future we could rebase to a more class-based structure.
  3. Set up continuous integration with GitHub Actions to test and check formatting

    • Using pytest for testing modules. Currently only testing calculate_velocity_advection with very simple test cases.
    • Using Ruff as a linter with black as the formatting standard.
  4. Miscellaneous updates

    • Dictionary data output
    • Gradient calculation updates throughout advection modules and structure function modules

Clear next steps related to these updates

cassidymwagner commented 8 months ago

I updated the main title and content of this pull request to include some information about new continuous integration with GitHub Actions to check the formatting and use pytest to complete some initial tests on multiple machines.

This is an addition I'm very excited about! The pull request is a bit bulkier now, but the CI tests and formatting will be very helpful to maintain this software package and encourage collaboration! 🎉