soandso / synop
Synop (AAXX/BBXX) 天气报告解码器
Requires
- php: >=7.4
Requires (Dev)
- mockery/mockery: ^1.5
- phpunit/phpunit: 9.6.x-dev
- squizlabs/php_codesniffer: 4.0.x-dev
README
Synop (AAXX/BBXX) 天气报告解码器
用于解码天气报告的SYNOP (AAXX) 字符串的PHP库。
您可以在演示网站上尝试该库
简介
此库组件是解码原始SYNOP 天气报告的解析器。
SYNOP (地面气象观测) 是一种用于报告由有人和自动化气象站进行的天气观测的数字代码(由WMO称为FM-12)。报告由描述气象参数的数字和符号组组成,这些参数在气象站进行观测。
更多详细信息请参阅 编码手册。国际编码。第一卷。世界气象组织,2011
存在以下形式的地面气象观测
- SYNOP - 来自固定陆地站的地面观测报告
- SHIP - 来自海上站的地面观测报告
- SYNOP MOBILE - 来自陆地移动站的地面观测报告
当前版本的库支持SYNOP代码格式。
要求
此库仅需要PHP >= 7.4
设置
将库添加到您的项目中的composer.json文件
{ "require": { "soandso/synop": "0.*" } }
使用composer 安装库
$ php composer.phar install
Composer将在您的vendor文件夹内安装synop解码器库。然后,您可以在.php文件中添加以下内容以使用库进行自动加载。
require_once(__DIR__ . '/vendor/autoload.php');
您还可以在命令行上使用composer来要求并安装分组
$ php composer.phar require soandso/synop
用法
使用SYNOP天气报告字符串实例化Report
类。要检查原始天气报告的validity
,请使用Report
对象的validate方法。
如果摘要格式有效,则可以获取解码的SYNOP参数。Report
对象包含用于获取解码数据的方法。
Report对象可用的方法
require_once dirname(__FILE__) . '/vendor/autoload.php'; use Soandso\Synop\Report; $report = new Report('AAXX 07181 33837 11583 83102 10039 21007 30049 40101 52035 60012 70282 8255/ 333 10091 555 1/004='); //Starts the decoding process $report->parse(); //Check validate format $report->validate(); //true //If the validate method returns false, you can use the getErrors method to display errors decoding the weather report //Returns errors in meteorological weather report. //If the validate method returns false, then the getErrors method will return an array of errors. //Otherwise, it returns false $report->getErrors() //false //Returns information about decoding errors in short form (error description only) $report->getErrorList() //false //Group YYGGiw //Get a type of weather station $report->getTypeStation(); //AAXX //Get a date (day) of a meteorological report $report->getDay(); //07 //Get a time (hour) of a meteorological report $report->getTime(); //18 //Get a unit of measure for wind speed $report->getUnitWind(); //m/s //Get a type of wind measurement $report->getWindDetection(); //Instrumental //Group IIiii //Area number of meteorological station $report->getAreaNumber(); //33 //Number of meteorological station $report->getStationNumber(); //837 //station index $report->getStationIndex(); //33837 //Group IrIxhVV //Index inclusion the precipitation group 6RRRtr $report->getInclusionPrecipitation(); //Included in section 1 //Weather indicator inclusion index 7wwW1W2 $report->getInclusionWeather(); //Included //Type station operation $report->getTypeStationOperation(); //Manned //Base height of low clouds above sea level $report->getHeightLowCloud(); //600-1000 //Unit for a base height of low clouds above sea level $report->getHeightLowCloudUnit(); //m //Meteorological range of visibility $report->getVisibility(); //45 //Unit for a meteorological range of visibility $report->getVisibilityUnit(); //km //Group NDDff //Total clouds $report->getTotalAmountCloud(); //10 //Direction of wind $report->getWindDirection(); //310 //Unit for direction of wind $report->getWindDirectionUnit(); //degrees //Wind speed $report->getWindSpeed(); //2 //Unit for wind speed $report->getWindSpeedUnit(); //m/s //Group 1SnTTT //Air temperature $report->getAirTemperature(); //3.9 //Unit for air temperature $report->getAirTemperatureUnit(); //degree C //Group 2SnTdTdTd //Dew point temperature $report->getDewPointTemperature(); //-0.7 //Unit for dew point temperature $report->getDewPointTemperatureUnit(); //degree C //Group 3P0P0P0 //Atmospheric pressure at station level $report->getStationLevelPressure(); //1004.9 //Unit for atmospheric pressure at station level $report->getStationLevelPressureUnit(); //hPa //Group 4PPPP //Atmospheric pressure reduced to mean sea level $report->getSeaLevelPressure(); //1010.1 //Unit for atmospheric pressure reduced to mean sea level $report->getSeaLevelPressureUnit(); //hPa //Group 5appp //Pressure change over last three hours $report->getBaricTendency(); //3.5 //Unit for pressure change over last three hours $report->getBaricTendencyUnit(); //hPa //Group 6RRRtr //Value of amount of rainfall $report->getAmountRainfall(); //1 //Unit for amount of rainfall $report->getAmountRainfallUnit(); //mm //Duration period of rainfall $report->getDurationPeriodRainfall(); //At 0600 and 1800 GMT //Group 7wwW1W2 //present weather $report->getPresentWeather(); //State of sky on the whole unchanged //Past weather $report->getPastWeather(); //array(2) { // ["W1"]=> // string(9) "Shower(s)" // ["W2"]=> // string(73) "Cloud covering more than 1/2 of the sky throughout the appropriate period" //} //Group 8NhClCmCH //Amount of low or middle cloud $report->getAmountLowOrMiddleCloud(); //2 eight of sky covered //Form of low cloud $report->getFormLowCloud(); //Stratocumulus not resulting from the spreading out of Cumulus //Form of medium cloud $report->getFormMediumCloud(); //Semi-transparent Altocumulus in bands, or Altocumulus in one or more fairly continuous layers (semi-transparent or opaque), progressively invading the sky; these Altocumulus clouds generally thicken as a whole //Form of high cloud $report->getFormHighCloud(); //Cirrus, Cirrocumulus and Cirrostartus invisible owing to darkness, fog, blowing dust or sand, or other similar phenomena or more often because of the presence of a continuous layer of lower clouds //Section 3 //Group 1SnTxTxTx //Maximum air temperature $report->getMaxAirTemperature(); //9.1 //Unit for maximum air temperature $report->getMaxAirTemperatureUnit(); //degree C //Group 2SnTnTnTn //Minimum air temperature $report->getMinAirTemperature(); //NULL //Unit for minimum air temperature $report->getMinAirTemperatureUnit(); //NULL //Group 3ESnTgTg //state of ground for case ground without snow or measurable ice cover $report->getStateGroundWithoutSnow(); //NULL //Grass minimum temperature for case ground without snow or measurable ice cover $report->getMinTemperatureOfGroundWithoutSnow(); //NULL //Unit for grass minimum temperature for case ground without snow or measurable ice cover $report->getMinTemperatureOfGroundWithoutSnowUnit(); //NULL //Group 4Esss //State of ground for case ground with snow or measurable ice cover $report->getStateGroundWithSnow(); //NULL //Depth of snow $report->getDepthSnow(); //NULL //Unit for depth of snow $report->getDepthSnowUnit(); //NULL //Group 55SSS //Duration of daily sunshine $report->getDurationSunshine(); //NULL //Unit for a duration of daily sunshine $report->getDurationSunshineUnit(); //NULL //Group 6RRRtr //Amount of rainfall $report->getRegionalExchangeAmountRainfall(); //NULL //Unit for amount of rainfall $report->getRegionalExchangeAmountRainfallUnit(); //NULL //Duration period of rainfall $report->getRegionalExchangeDurationPeriodRainfall(); //NULL //Group 8NsChshs //Amount of individual cloud layer $report->getAmountIndividualCloudLayer(); //NULL //Form of cloud (additional cloud information) $report->getFormCloud(); //NULL //Height of base of cloud layer (additional cloud information) $report->getHeightCloud(); //NULL //Unit for a form of cloud (additional cloud information) $report->getHeightCloudUnit(); //NULL
贡献
如果您发现此库未能很好地解析某个SYNOP报告,请尽可能详细地打开一个GitHub问题。
为了改进测试套件,请分叉存储库并使用拉取请求推送您的更改。
如果您有改进库的想法,开发新功能,使用GitHub问题或直接拉取请求。要为代码库做出贡献,您应该在GitHub上分叉存储库,然后在本地克隆它。更改代码并提交拉取请求。
程序代码的文档可以在docs
目录中查看。
Report
类的主要方法之一 - parse()
的简化序列图。
代码质量和测试覆盖率由Codacy服务分析。
标准
SYNOP符合以下标准
- PSR-2 - 基本编码标准 (https://www.php-fig.org/psr/psr-2/)
- PSR-4 - 自动加载 (https://www.php-fig.org/psr/psr-4/)
- PSR-12 - 扩展编码风格指南 (https://www.php-fig.org/psr/psr-12/)
许可证
分组软件遵循GPLv2许可证(https://gnu.ac.cn/licenses/old-licenses/gpl-2.0.html)。