printer.c
来自「麻省理工学院的人工智能工具箱,很珍贵,希望对大家有用!」· C语言 代码 · 共 696 行 · 第 1/2 页
C
696 行
fprintf(fp," U&V components resolved relative to +I and " "+J\n"); else fprintf(fp," U&V components resolved relative to east " "and north.\n"); fprintf(fp,"Scanning Mode Flags: \n"); if ((gds.llg.usScan_mode >> 7) & 1) fprintf(fp," Points scan in -I direction.\n"); else fprintf(fp," Points scan in +I direction.\n"); if ((gds.llg.usScan_mode >> 6) & 1) fprintf(fp," Points scan in +J direction.\n"); else fprintf(fp," Points scan in -J direction.\n"); if ((gds.llg.usScan_mode >> 5) & 1) fprintf(fp," Adjacent points in J direction are " "consecutive.\n"); else fprintf(fp," Adjacent points in I direction are " "consecutive.\n"); break;/** Case 1: Mercator Projection*/ case 1: /* Mercator Projection Grid */ fprintf(fp,"Projection = Mercator\n"); fprintf(fp,"Number of points along a parallel = %d\n",gds.merc.cols); fprintf(fp,"Number of points along a meridian = %d\n",gds.merc.rows); fprintf(fp,"Latitude of first grid point = %.3f deg\n", ((float)gds.merc.first_lat)/1000.); fprintf(fp,"Longitude of first grid point = %.3f deg\n", ((float)gds.merc.first_lon)/1000.); fprintf(fp,"Latitude of last grid point = %.3f deg\n", ((float)gds.merc.La2)/1000.); fprintf(fp,"Longitude of last grid point = %.3f deg\n", ((float)gds.merc.Lo2)/1000.); fprintf(fp,"Latitude of intersection with Earth = %.3f deg\n", ((float)gds.merc.latin)/1000.); fprintf(fp,"Resolution and Component Flags: \n"); if ((gds.merc.usRes_flag >> 7) & 1) { fprintf(fp," Longitudinal increment = %f deg\n", ((float)gds.merc.lon_inc)/1000.); fprintf(fp," Latitudinal increment = %f deg\n", ((float)gds.merc.lat_inc)/1000.); }else fprintf(fp," Direction increments not given.\n"); if ((gds.merc.usRes_flag >> 6) & 1) fprintf(fp," Earth assumed oblate spherical.\n"); else fprintf(fp," Earth assumed spherical.\n"); if ((gds.merc.usRes_flag >> 3) & 1) fprintf(fp," U&V components resolved relative to +I and " "+J\n"); else fprintf(fp," U&V components resolved relative to east " "and north.\n"); fprintf(fp,"Scanning Mode Flags: \n"); if ((gds.merc.usScan_mode >> 7) & 1) fprintf(fp," Points scan in -I direction.\n"); else fprintf(fp," Points scan in +I direction.\n"); if ((gds.merc.usScan_mode >> 6) & 1) fprintf(fp," Points scan in +J direction.\n"); else fprintf(fp," Points scan in -J direction.\n"); if ((gds.merc.usScan_mode >> 5) & 1) fprintf(fp," Adjacent points in J direction are " "consecutive.\n"); else fprintf(fp," Adjacent points in I direction are " "consecutive.\n"); break;/** Case 3: Lambert Conformal Projection*/ case 3: /* Lambert conformal, secant or tangent, conical or bipolar Projection Grid */ fprintf(fp,"Projection = Lambert Conformal\n"); fprintf(fp,"Number of points along X-axis = %d\n",gds.lam.iNx); fprintf(fp,"Number of points along Y-axis = %d\n",gds.lam.iNy); fprintf(fp,"Latitude of first grid point = %.3f deg\n", ((float)gds.lam.lLat1)/1000.); fprintf(fp,"Longitude of first grid point = %.3f deg\n", ((float)gds.lam.lLon1)/1000.); fprintf(fp,"Orientation of grid = %.3f deg\n", ((float)gds.lam.lLon_orient)/1000.); fprintf(fp,"First Latitude Cut = %.3f deg\n", ((float)gds.lam.lLat_cut1)/1000.); fprintf(fp,"Second Latitude Cut = %.3f deg\n", ((float)gds.lam.lLat_cut2)/1000.); fprintf(fp,"Resolution and Component Flags: \n"); if ((gds.lam.usRes_flag >> 7) & 1) { fprintf(fp," X-direction increment = %d meters\n", gds.lam.ulDx); fprintf(fp," Y-direction increment = %d meters\n", gds.lam.ulDy); }else fprintf(fp," Direction increments not given.\n"); if ((gds.lam.usRes_flag >> 6) & 1) fprintf(fp," Earth assumed oblate spherical.\n"); else fprintf(fp," Earth assumed spherical.\n"); if ((gds.lam.usRes_flag >> 3) & 1) fprintf(fp," U&V components resolved relative to +I and " "+J\n"); else fprintf(fp," U&V components resolved relative to east " "and north.\n"); fprintf(fp,"Scanning Mode Flags: \n"); if ((gds.lam.usScan_mode >> 7) & 1) fprintf(fp," Points scan in -I direction.\n"); else fprintf(fp," Points scan in +I direction.\n"); if ((gds.lam.usScan_mode >> 6) & 1) fprintf(fp," Points scan in +J direction.\n"); else fprintf(fp," Points scan in -J direction.\n"); if ((gds.lam.usScan_mode >> 5) & 1) fprintf(fp," Adjacent points in J direction are " "consecutive.\n"); else fprintf(fp," Adjacent points in I direction are " "consecutive.\n"); break;/** Case 4: Gaussian Latitude/Longitude Projection*/ case 4: /* Gaussian Latitude/Longitude Grid */ fprintf(fp,"Projection = Gaussian Latitude/Longitude\n"); fprintf(fp,"Number of points along a parallel = %d\n",gds.llg.usNi); fprintf(fp,"Number of points along a meridian = %d\n",gds.llg.usNj); fprintf(fp,"Latitude of first grid point = %.3f deg\n", ((float)gds.llg.lLat1)/1000.); fprintf(fp,"Longitude of first grid point = %.3f deg\n", ((float)gds.llg.lLon1)/1000.); fprintf(fp,"Latitude of last grid point = %.3f deg\n", ((float)gds.llg.lLat2)/1000.); fprintf(fp,"Longitude of last grid point = %.3f deg\n", ((float)gds.llg.lLon2)/1000.); fprintf(fp,"Resolution and Component Flags: \n"); if ((gds.llg.usRes_flag >> 7) & 1) { fprintf(fp," i direction increment = %f deg\n",((float)gds.llg.iDi)/1000.); fprintf(fp," Number of parallels between pole and equator = %d\n",gds.llg.iDj); }else fprintf(fp," Direction increments not given.\n"); if ((gds.llg.usRes_flag >> 6) & 1) fprintf(fp," Earth assumed oblate spherical.\n"); else fprintf(fp," Earth assumed spherical.\n"); if ((gds.llg.usRes_flag >> 3) & 1) fprintf(fp," U&V components resolved relative to +I and " "+J\n"); else fprintf(fp," U&V components resolved relative to east " "and north.\n"); fprintf(fp,"Scanning Mode Flags: \n"); if ((gds.llg.usScan_mode >> 7) & 1) fprintf(fp," Points scan in -I direction.\n"); else fprintf(fp," Points scan in +I direction.\n"); if ((gds.llg.usScan_mode >> 6) & 1) fprintf(fp," Points scan in +J direction.\n"); else fprintf(fp," Points scan in -J direction.\n"); if ((gds.llg.usScan_mode >> 5) & 1) fprintf(fp," Adjacent points in J direction are " "consecutive.\n"); else fprintf(fp," Adjacent points in I direction are " "consecutive.\n"); break;/** Case 5: Polar Sterographic Projection*/ case 5: /* Polar Stereographic Projection Grid */ fprintf(fp,"Projection = Polar Stereographic\n"); fprintf(fp,"Number of points along X-axis = %d\n",gds.pol.usNx); fprintf(fp,"Number of points along Y-axis = %d\n",gds.pol.usNy); fprintf(fp,"Latitude of first grid point = %.3f deg\n", ((float)gds.pol.lLat1)/1000.); fprintf(fp,"Longitude of first grid point = %.3f deg\n", ((float)gds.pol.lLon1)/1000.); fprintf(fp,"Orientation of grid = %.3f deg\n", ((float)gds.pol.lLon_orient)/1000.); fprintf(fp,"Projection Center: "); if ((gds.pol.usProj_flag >> 7) & 1) fprintf(fp,"South Pole\n"); else fprintf(fp,"North Pole\n"); fprintf(fp,"Resolution and Component Flags: \n"); if ((gds.pol.usRes_flag >> 7) & 1) { fprintf(fp," X-direction grid length = %d meters\n",gds.pol.ulDx); fprintf(fp," Y-direction grid length = %d meters\n",gds.pol.ulDy); }else fprintf(fp," Direction increments not given.\n"); if ((gds.pol.usRes_flag >> 6) & 1) fprintf(fp," Earth assumed oblate spherical.\n"); else fprintf(fp," Earth assumed spherical.\n"); if ((gds.pol.usRes_flag >> 3) & 1) fprintf(fp," U&V components resolved relative to +I and " "+J\n"); else fprintf(fp," U&V components resolved relative to east " "and north.\n"); fprintf(fp,"Scanning Mode Flags: \n"); if ((gds.pol.usScan_mode >> 7) & 1) fprintf(fp," Points scan in -I direction.\n"); else fprintf(fp," Points scan in +I direction.\n"); if ((gds.pol.usScan_mode >> 6) & 1) fprintf(fp," Points scan in +J direction.\n"); else fprintf(fp," Points scan in -J direction.\n"); if ((gds.pol.usScan_mode >> 5) & 1) fprintf(fp," Adjacent points in J direction are " "consecutive.\n"); else fprintf(fp," Adjacent points in I direction are " "consecutive.\n"); break; default: /* no others are currently implemented */#ifdef MATLAB_MEX_FILE mexErrMsgTxt("This projection is not currently implemented.\n");#else printf("This projection is not currently implemented.\n"); exit(0);#endif/** A.4.2 ENDSWITCH (Data Type)*/ } /* Switch */ } /* gds included *//*** A.4 ELSE * PRINT no Gds message* A.4 ENDIF*/ else fprintf(fp,"\n******* NO SECTION 2 GDS *********\n" );/*** A.5 IF (Bitmap Section is present)* THEN* WRITE Bitmap Section information to file* ELSE* PRINT no bms mesg* ENDIF*/ if(pds.usGds_bms_id >> 6 & 1) { fprintf(fp,"\n********* SECTION 3 BMS **********\n" ); fprintf(fp,"Section length = %ld\n", bms.uslength); if (bms.uslength <= 6) fprintf(fp,"Bitmap is predefined (Not in message).\n"); else fprintf(fp,"Bitmap is included with message.\n"); fprintf(fp,"Bitmap ID = %d \n", bms.usBMS_id); fprintf(fp,"Number of unused bits = %d\n", bms.usUnused_bits); fprintf(fp,"Number of datapoints set = %ld\n", bms.ulbits_set); }else{ fprintf(fp,"\n******* NO SECTION 3 BMS *********\n" ); }/*** A.6 WRITE out Binary Data Section Information to file * !Section Length*/ fprintf(fp,"\n********* SECTION 4 BDS *********\n" ); fprintf(fp,"Section length = %ld\n",bds.length);/** !Table 11 Flags*/ fprintf(fp,"Table 11 Flags:\n"); if ((bds.usBDS_flag >> 7) & 1) fprintf(fp," Spherical harmonic coefficients.\n"); else fprintf(fp," Grid-point data.\n"); if ((bds.usBDS_flag >> 6) & 1) fprintf(fp," Second-order packing.\n"); else fprintf(fp," Simple Packing.\n"); if ((bds.usBDS_flag >> 5) & 1) fprintf(fp," Integer values.\n"); else fprintf(fp," Floating point values.\n"); if ((bds.usBDS_flag >> 4) & 1) fprintf(fp," Octet 14 contains additional flag bits.\n"); else fprintf(fp," No additional flags at octet 14.\n");/** !Decimal Scale Factor (Repeated from PDS)*/ fprintf(fp,"\nDecimal Scale Factor = %d\n",pds.sDec_sc_fctr);/** !Binary Scale Factor* !Bit Width* !Number of Data Points*/ fprintf(fp,"Binary scale factor = %d\n", bds.Bin_sc_fctr); fprintf(fp,"Bit width = %d\n", bds.usBit_pack_num); fprintf(fp,"Number of data points = %ld\n",bds.ulGrid_size);/** A.6.1 WRITE Data Summary to file* !Compute Data Min/Max and Resolution*/ dsf = (float) pow( (double) 10, (double) pds.sDec_sc_fctr); res = (float) pow((double)2,(double)bds.Bin_sc_fctr) / dsf; min = bds.fReference / dsf; max = (float) (pow((double)2, (double)bds.usBit_pack_num) - 1); max = min + max * res; fprintf(fp,"Data Minimum = %f\n", min ); fprintf(fp,"Data Maximum = %f\n", max ); fprintf(fp,"Resolution = %f\n",res );/** !Compute Format Specifier for printing Data*/ fd = (int)( -1 * (float) log10((double) res) + .5); if (fd <= 0) { fd = 0; fprintf(fp,"DATA will be displayed as integers (res > 0.1).\n"); }/** !WRITE First 100 Data Points to file*/ if (bds.ulGrid_size > 1) { if (bds.ulGrid_size < 100) numpts = bds.ulGrid_size; fprintf(fp,"\nDATA ARRAY: (first %d)\n",numpts); for (i=0; i<numpts; i=i+5) { fprintf(fp, "%02d- %.*f %.*f %.*f %.*f %.*f\n", i,fd,grib_data[i],fd,grib_data[i+1],fd, grib_data[i+2],fd,grib_data[i+3],fd,grib_data[i+4] ); } } fprintf (fp,"\n******** END OF MESSAGE *******\n\n");/** * A.7 CLOSE file*/ fclose (fp);/*** A.8 DEBUG printing*/ DPRINT ("Exiting printer(), no return code\n");/** END OF printer()***/}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?