38 g2int *ifld, j, iofst, nbits;
39 float ref, bscale, dscale, *unpk;
40 float *pscale, tscale;
41 g2int Js, Ks, Ms, Ts, Ns, Nm, n, m;
42 g2int inc, incu, incp;
44 rdieee(idrstmpl + 0, &ref, 1);
56 unpk = malloc(ndpts *
sizeof(
float));
57 ifld = malloc(ndpts *
sizeof(
g2int));
59 gbits(cpack, ifld, 0, 32, 0, Ts);
62 gbits(cpack, ifld, iofst, nbits, 0, ndpts - Ts);
66 pscale = malloc((JJ + MM + 1) *
sizeof(
float));
67 tscale = idrstmpl[4] * 1E-6;
68 for (n = Js; n <= JJ + MM; n++)
69 pscale[n] = pow((
float)(n * (n + 1)), -tscale);
75 for (m = 0; m <= MM; m++)
83 for (n = m; n <= Nm; n++)
85 if (n <= Ns && m <= Ms)
87 fld[inc++] = unpk[incu++];
88 fld[inc++] = unpk[incu++];
92 fld[inc++] = (((float)ifld[incp++] * bscale) + ref) *
94 fld[inc++] = (((float)ifld[incp++] * bscale) + ref) *
106 printf(
"specunpack: Cannot handle 64 or 128-bit floats.\n");
107 for (j = 0; j < ndpts; j++)
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked io...
void rdieee(g2int *rieee, float *a, g2int num)
Read a list of real values in 32-bit IEEE floating point format.
g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ, g2int KK, g2int MM, float *fld)
Unpack a spectral data field that was packed using the complex packing algorithm for spherical harmon...