o pf @sRddlZddlmZddlZGdddejZGdddejZGdddZdS) N)nncs&eZdZdfdd ZddZZS) NormGPSgpsx_0TcsRt||_||_||_|jr'|ddttj dtj g ddSdS)N gps_normalizeg?r) super__init__ input_key output_key normalizeregister_buffertorchTensornppi unsqueeze)selfr r r  __class__9/home/dufour/Documents/diff_plonk/models/preprocessing.pyr s  zNormGPS.__init__cCs(||j}|jr ||j}|||j<|S)z/Normalize latitude longtitude radians to -1, 1.)r r rr )rbatchxrrrforwards   zNormGPS.forward)rrT__name__ __module__ __qualname__r r __classcell__rrrrrs rcs&eZdZdfdd ZddZZS)GPStoCartesianrrcst||_||_dSN)rr r r rr r rrrr s  zGPStoCartesian.__init__cCsj||j}|dddf|dddf}}tj|||||gdd}|||j<|S)z6Project latitude longtitude radians to 3D coordinates.Nrr)dim)r rstackcossinr )rrrlatlonrrrrs "0 zGPStoCartesian.forward)rrrrrrrr sr c@s$eZdZ  dddZdddZdS) PrecomputedPreconditioningembcCs||_||_dSr!r r r"rrrr (s z#PrecomputedPreconditioning.__init__NcCs||j||j<|Sr!r,)rrdevicerrr__call__0sz#PrecomputedPreconditioning.__call__)r+r+r!)rrrr r.rrrrr*'s  r*)rrnumpyrModulerr r*rrrrs