sampotter / fluxpy

Fast thermal modeling and radiosity in Python.
11 stars 5 forks source link

Different incidence angle for each pixel #41

Closed nschorgh closed 2 years ago

nschorgh commented 2 years ago

Please consider this addition to shape.py, which allows each pixel to have a different incidence angle. This will interpret an array of sun directions of the same length as the number of topographic pixels as a lat/lon dependence.

       # Compute the direct irradiance
        if Dsun.ndim == 1:
            E = np.zeros(n, dtype=self.dtype)
            E[I] = F0*np.maximum(0, self.N[I]@Dsun)
        elif n==m: #### new option
            E = np.zeros(n, dtype=self.dtype)
            for i in range(n):
                if I[i]:
                    E[i] = F0*np.maximum(0, self.N[i,:]@Dsun[i,:])
        else:
            E = np.zeros((n, m), dtype=self.dtype)
            I = I.reshape(m, n)
            for i, d in enumerate(Dsun):
                E[I[i], i] = F0*np.maximum(0, self.N[I[i]]@d)
        return E

And the value of m will have to be assigned outside of the previous if construct.

steo85it commented 2 years ago

(Just seen it now) What would you like to model with that addition? An extended Sun disk or some terrain property?

nschorgh commented 2 years ago

The permanently shadowed regions of Ceres with a point-like sun. But you will also need this for Haworth, which spans a non-negligible range of latitudes.

steo85it commented 2 years ago

Ok, I was just asking because I already had to implement/use modifications for a non-pointlike Sun for Mercury, and wondered if those could be useful here.

nschorgh commented 2 years ago

The existing Dsun.ndim==2 option was presumably intended for a non-pointlike Sun, but this returns a much bigger array.

steo85it commented 2 years ago

Ah ops, already pushed it and forgot about. Erase that, sorry. I'll check your mods!

nschorgh commented 2 years ago

I haven't modified anything in shape.py

steo85it commented 2 years ago

I meant those here in the issue :)

sampotter commented 2 years ago

This is a useful thing to add, I agree. Please feel free to include it and make a pull request or just commit the change.

nschorgh commented 2 years ago

I just tried to re-implement this, but now basemesh is some sort of higher dimensional object as soon as Dsun.ndim==2, so I can't get this line to work I = ~basemesh.is_occluded(np.arange(self.num_faces), Dsun) even if I explicitly loop through the triangles.

nschorgh commented 2 years ago

@sampotter Thanks! I still get a strange error about ndarray not being C-contiguous, although the very same program works if I only use a single dir_sun vector. Try

./examples/ceres/generate_mesh_from_grd.py
./examples/ceres/psr_ceres.py
steo85it commented 2 years ago

That's easy to solve (I recently learnt from Sam): just change your vector to v=v.copy(order='C').Happy holidays, too!Stefano -------- Messaggio originale --------Da: Norbert Schörghofer @.> Data: 24/12/21 1:45 AM (GMT+01:00) A: sampotter/python-flux @.> Cc: Stefano Bertone @.>, State change @.> Oggetto: Re: [sampotter/python-flux] Different incidence angle for each pixel (Issue #41) @sampotter Thanks! I still get a strange error about ndarray not being C-contiguous, although the very same program works if I only use a single dir_sun vector. Try ./examples/ceres/generate_mesh_from_grd.py ./examples/ceres/psr_ceres.py

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you modified the open/close state.Message ID: @.***>

nschorgh commented 2 years ago

Thanks. That got me one step closer.

nschorgh commented 2 years ago

Works now. Had to change one line in shape.py though.