CoolFace
Apppublic

procgne/Plonk

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
preprocessing.cpython-310.pyc25 linesDownload Raw Back to __pycache__
1o

2�p�f�@sRddlZddlmZddlZGdd�dej�ZGdd�dej�ZGdd�d�ZdS)	�N)�nncs&eZdZd�fdd�	Zdd�Z�ZS)	�NormGPS�gps�x_0TcsRt���||_||_||_|jr'|�ddt�tj	dtj	g��3d��dSdS)N�
gps_normalize�g�?r)�super�__init__�	input_key�4output_key�	normalize�register_buffer�torch�Tensor�np�pi�	unsqueeze)�selfr5rr��	__class__��9/home/dufour/Documents/diff_plonk/models/preprocessing.pyr	s6 ��zNormGPS.__init__cCs(||j}|jr
||j}|||j<|S)z/Normalize latitude longtitude radians to -1, 1.)r7rrr)r�batch�xrrr�forwards891011zNormGPS.forward)rrT��__name__�12__module__�__qualname__r	r�
__classcell__rrrrrs13rcs&eZdZd�fdd�	Zdd�Z�ZS)�GPStoCartesianrrcst���||_||_dS�N)rr	r14r�rr15rrrrr	s1617zGPStoCartesian.__init__cCsj||j}|dd�df|dd�df}}tj|��|��|��|��|��gdd�}|||j<|S)z6Project latitude longtitude radians to 3D coordinates.Nrr�����)�dim)r18r�stack�cos�sinr)rrr�lat�lonrrrrs1920"021zGPStoCartesian.forward)rrrrrrrr sr c@s$eZdZ		ddd�Zddd�ZdS)	�PrecomputedPreconditioning�embcCs||_||_dSr!�r22rr"rrrr	(s23z#PrecomputedPreconditioning.__init__NcCs||j||j<|Sr!r,)rr�devicerrr�__call__0sz#PrecomputedPreconditioning.__call__)r+r+r!)rrrr	r.rrrrr*'s2425�r*)rr�numpyr�Modulerr r*rrrr�<module>s