GRASP结构

 

上图为GRASP软件包中包含的文件,其中关键的算法部分包含在src文件夹中。

下方链接是GRASP官方提供的文件目录。

http://www.grasp-open.com/tech-doc/dir_68267d1309a1af8e8297ef4c3efbcdba.phphttp://www.grasp-open.com/tech-doc/dir_68267d1309a1af8e8297ef4c3efbcdba.php一、forward_model 结构整理

 

 1.1 .1example_fw.c

radiative_transfer_args 是 external_interface.h 中定义的结构体 ,external_interface.h 代码如下: radiative_transfer_args_ 定义了辐射传输的输入参数;radiative_transfer_result_ 定义了输出结果参数;grasp_rt_sos函数定义了辐射传输所需的所有参数(输入+输出)。

#include <stdbool.h>
#include "mod_par_OS.inc"
#include "mod_par_DLS.inc"
#include "mod_par_inv.inc"

#ifndef EXTERNAL_INTERFACE_H
#define EXTERNAL_INTERFACE_H
#define MAX(x,y) ((x>y)?x:y)

#define _NLEVEL_GAS _KVERT_WD

typedef struct radiative_transfer_args_ {
    int IW;  /**< @brief IW: Index of the position of the wavelength  */
    int NG;  /**< @brief NG - Number of gaussian quadrature points */
    int NN;  /**< @brief NN - Number of quadrature expansions */
    int NF;  /**< @brief NF - Maximum number of Fourier terms */
    int iBRDF;  /**< @brief iBRDF - Establish if surface directional scattering is taken into account */
    int iBPDF;  /**< @brief iBPDF - Establish if surface polarization is taken into */
    int iBRM_water;  /**< @brief iBRM_water - Type of water surface model */
    float land_percent;  /**< @brief land_percent - Percent of surface corresponding to land model */
    int NQDR;  /**< @brief NQDR - Number of angular quadrature points */
    int NT1[2];  /**< @brief NT1 - Number of layers */
    float tetas;  /**< @brief tetas - Solar Zenith Angle */
    int NBV;  /**< @brief NBV - Number of observations */
    float vis[2 * _NBVM];  /**< @brief vis - Observation Zenith angle (degrees) */
    float fiv[2 * _NBVM];  /**< @brief fiv - Observation Azimuth angle (degrees) */
    float WAVE;  /**< @brief WAVE - Wavelength in micrometers */
    int n_par_land;  /**< @brief n_par_land - total number of surface parameters (BRDF+BPDF) for land */
    int n_par_land_i;  /**< @brief n_par_land_i - number of BRDF surface parameters for land */
    float surf_land_par_vect[2 * _KBF];  /**< @brief surf_land_par_vect - Parameters describing land surface */
    int n_par_water;  /**< @brief n_par_water - number of BRDF surface parameters for water */
    float surf_water_par_vect[_KBF];  /**< @brief surf_water_par_vect - Parameters describing water surface */
    float EXT[_NMM + _NMG];  /**< @brief EXT - Extinction for each */
    float SSA[_NMM + _NMG];  /**< @brief SSA - Single scattering albedo for each atmospheric component */
    int NANG;  /**< @brief NANG - number of scattering angles of phase matrix NANG */
    float ANGL[_KMpar];  /**< @brief ANGL - Scattering angles in which is defined PF11_I */
    float SD[_KIDIM3][_KSD];  /**< @brief SD - RT kernels approach: Size distribution. Related to LUT generation */
    float CEXT[_KSD];  /**< @brief CEXT - RT kernels approach: extinction. Related to LUT generation */
    float HOBS_km;  /**< @brief HOBS_km - Height of observation in km */
    float HGR_km;  /**< @brief HGR_km - Station altitude in km */
    float HMAX_atm_km;  /**< @brief HMAX_atm_km - Atmosphere maximum altitude */
    int NHVP_retr;  /**< @brief NHVP_retr - Number of altitudes for retrieved vertical profile */
    float HVP_retr_km[_KVERTM];  /**< @brief HVP_retr_km - Altitudes for retrieved vertical profile */
    float H0[_KVERTM][_KSD];  /**< @brief H0 - Contains parameters of aerosol vertical distribution or distribution itself */
    float sigma_aerosol[_KSD];  /**< @brief sigma_aerosol - Parameters for aerosol vertical profile shape */
    int ifgas;  /**< @brief ifgas - Selects if gas absorption is incuded or not (old gas model) */
    float gaspar;  /**< @brief gaspar - Gas absorption value  (old gas model) */
    float T_profile[_NLEVEL_GAS];  /**< @brief T_profile - Temperature profile for each level Only necessary if emission is accounted */
    float STEMP;  /**< @brief STEMP - Surface temperature. Only necesary if emission is accounted */
    bool laerosol;  /**< @brief laerosol - Selects if aerosol is present in the atmosphere */
    bool lsurface;  /**< @brief lsurface - Selects if surface is present in the calculations */
    bool ATMOS_EMIS;  /**< @brief ATMOS_EMIS - To account for thermal emission */
    bool SOLAR_EMIS;  /**< @brief SOLAR_EMIS - If emission is accounted it is used  to account for solar contribution */
    float PF11_I[_KMpar][_KSD];  /**< @brief PF11_I - Aerosol phase matrix */
    float PF12_I[_KMpar][_KSD];  /**< @brief PF12_I - Aerosol phase matrix */
    float PF22_I[_KMpar][_KSD];  /**< @brief PF22_I - Aerosol phase matrix */
    float PF33_I[_KMpar][_KSD];  /**< @brief PF33_I - Aerosol phase matrix */
    int NLV;  /**< @brief NLV - Number of levels */
    float HLV[_KNT];  /**< @brief HLV - Height of levels */
    int aerosol_analyt_prof;  /**< @brief aerosol_analyt_prof - Marks if the the exact aerosol profiles is known or an analytic shape is going to be taken */
    int gas_abs_line;  /**< @brief gas_abs_line - Marks if there is gas absorption included (new model) */
    int N_level;  /**< @brief N_level - Number of levels */
    float Hight_level_km[MAX(_KVERTM, _KVERT_WD)];  /**< @brief Hight_level_km - Aerosol profile height */
    int nh;  /**< @brief nh - Number of layers in the aerosol profile */
    float h_km[_KVERT_WD];  /**< @brief h_km - Height of layers in the aerosol profile */
    int natm;  /**< @brief natm - Number of total atmospheric components */
    int naer;  /**< @brief naer - Number of total aerosol modes */
    int nmol;  /**< @brief nmol - Number of total molecular components */
    int ngas;  /**< @brief ngas - Number of total gaseous components */
    float norm_DISCRVD[_NMM + _NMG];  /**< @brief norm_DISCRVD - Norm of atmospheric vertical profile */
    bool ISGL;  /**< @brief ISGL - To restrict the code to single scattering calculations */
    bool IAER;  /**< @brief IAER - Selects if aerosol must be considered */
    bool IVEC_CTL;  /**< @brief IVEC_CTL - To restrict the calculation to scalar equations */
    bool ISRF;  /**< @brief ISRF - Selects if surface must be accounted */
    bool IDWN;  /**< @brief IDWN - Marks if the calculations are upwards or downwards */
    bool IFLX;  /**< @brief IFLX - Marks is flux calculations is going to be done (not possible with the actual approach of the stand alone RT) */
    bool IGQ_F;  /**< @brief IGQ_F - Quadrature calculation in forward mode */
    bool IGQ_D;  /**< @brief IGQ_D -  Quadrature calculation for dericatives in inversion mode */
    bool IGQ_BRM_FEXP;  /**< @brief IGQ_BRM_FEXP - Surface quadrature calculations for Fourier components */
    bool IGQ_BRM_HSPH;  /**< @brief IGQ_BRM_HSPH - High precision surface quadrature calculations */
    bool IP_VERBOSE;  /**< @brief IP_VERBOSE - Related with output format */
    bool IP_ADDITION;  /**< @brief IP_ADDITION - Related with output additional information */
    bool ITRC;  /**< @brief ITRC - Marks if Phase matrix truncation is going to be done */
    bool ISCA;  /**< @brief ISCA - Output in scattering or meridian plane */
    bool IVEC_SET;  /**< @brief IVEC_SET - Scalar or vector calculations */
    bool IWUT;  /**< @brief IWUT - Lut generation */
    bool ILUT;  /**< @brief ILUT - Use LUTs already generated */
    bool IATM;  /**< @brief IATM - Choose between bihemispherical or directional hemispherical reflectance of atmosphere */
    bool ICRR;  /**< @brief ICRR - Atmospheric correction */
    bool boa_ref;  /**< @brief boa_ref - Selectes between different surface models */
    int AER_PRF;  /**< @brief AER_PRF - Aerosol profile shape */
    int MOL_PRF;  /**< @brief MOL_PRF - Molecular profile shape */
    int NA;  /**< @brief NA - RT kernels approach: number of aerosol modes */
    int NB[_KSD];  /**< @brief NB - RT kernels appraoch: number of aerosol */
    int NLYR[2];  /**< @brief NLYR - Number of layers */
    float EPS;  /**< @brief EPS - Related with precision of some  numerical expansions */
} radiative_transfer_args;

typedef struct radiative_transfer_result_ {
    float thd[2*_NBVM];  /**< @brief thd - Measurement azimuth angle (degrees) */
    float SLout[2*_NBVM];  /**< @brief SLout - Calculated radiance in the selected viewing geometry */
    float SQout[2*_NBVM];  /**< @brief SQout - Calculated radiance in the selected viewing geometry */
    float SUout[2*_NBVM];  /**< @brief SUout - Calculated radiance in the selected viewing geometry*/
    float SLPout[2*_NBVM];  /**< @brief SLPout - Calculated radiance in the selected viewing geometry */
    float salb_out;  /**< @brief salb_out - Surface albedo */
    float UFX[_KNT];  /**< @brief UFX - Fluxes */
    float DFX[_KNT];  /**< @brief DFX - Fluxes */
} radiative_transfer_result;

/*
 * Actual function is implemented in fortran, which is why we have the full list of parameters here as well
 */
extern void grasp_rt_sos_(int IW, int NG, int NN, int NF,
                          int iBRDF, int iBPDF, int iBRM_water, float land_percent,
                          int NQDR, int NT1[2], float tetas, int NBV, float vis[2*_NBVM], float fiv[2*_NBVM],
                          float WAVE,
                          int n_par_land, int n_par_land_i, float surf_land_par_vect[2*_KBF],
                          int n_par_water, float surf_water_par_vect[_KBF],
                          float EXT[_NMM+_NMG], float SSA[_NMM+_NMG],
                          int NANG, float ANGL[_KMpar],
                          float SD[_KIDIM3][_KSD], float CEXT[_KSD],
                          float HOBS_km, float HGR_km, float HMAX_atm_km,
                          int NHVP_retr, float HVP_retr_km[_KVERTM],
                          float H0[_KVERTM][_KSD], float sigma_aerosol[_KSD],
                          int ifgas, float gaspar,
                          float T_profile[_NLEVEL_GAS], float STEMP,
                          bool laerosol, bool lsurface,
                          bool ATMOS_EMIS, bool SOLAR_EMIS,
                          float PF11_I[_KMpar][_KSD], float PF12_I[_KMpar][_KSD],
                          float PF22_I[_KMpar][_KSD], float PF33_I[_KMpar][_KSD],
                          int NLV, float HLV[_KNT],
                          int  aerosol_analyt_prof, int gas_abs_line,
                          int N_level,
                          float Hight_level_km[MAX(_KVERTM,_KVERT_WD)],
                          int nh,
                          float h_km[_KVERT_WD],
                          int natm, int naer, int nmol, int ngas,
                          float norm_DISCRVD[_NMM+_NMG],
                          bool ISGL, bool IAER, bool IVEC_CTL, bool ISRF, bool IDWN, bool IFLX,
                          bool IGQ_F, bool IGQ_D, bool IGQ_BRM_FEXP, bool IGQ_BRM_HSPH,
                          bool IP_VERBOSE, bool IP_ADDITION, bool ITRC, bool ISCA, bool IVEC_SET,
                          bool IWUT, bool ILUT, bool IATM, bool ICRR, bool boa_ref,
                          int AER_PRF, int MOL_PRF,
                          int NA, int NB[_KSD],
                          int NLYR[2], float EPS,
                          float thd[2*_NBVM],
                          float SLout[2*_NBVM], float SQout[2*_NBVM], float SUout[2*_NBVM], float SLPout[2*_NBVM],
                          float *salb_out,
                          float UFX[_KNT], float DFX[_KNT]);

void grasp_rt_sos(radiative_transfer_args *args, radiative_transfer_result *result);

#endif //EXTERNAL_INTERFACE_H

所以,example_fw.c 对辐射传输进行了初始化赋值。(并无计算过程,example)

1.1.2 example_fw.f90

初始化辐射传输的相关参数,并调用了(call)external_interface.f90文件中的grasp_rt_sos子程序。

在grasp_rt_sos子程序中,又调用了下面两个子程序,分别是有关气体垂直分布、辐射传输的子程序。(后续详细介绍)

 1.2 radiative_transfer/rt_sos

 1.2.1 mod_par_os.f90

定义一些参数并赋值

1.2.2 mod_rt_sos_lut.f90

有关辐射传输过程中的LUT操作

二分查找AOD1在查找表中的位置:

 进而计算出辐射传输中的相关参数

 

 1.2.3 mod_rt_sos_ms.f90

有关辐射传输中多次散射的计算,具体内容可参考源代码中的注释。1

1.2.4 mod_rt_sos_setup.f90

"

DESCRIPTION:

!> setup and control flags in radiative transfer

"

1.2.5 mod_rt_sos.f90

 

SUBROUTINE radiative_transfer_SOS

subroutine surface1

subroutine aerosol1

SUBROUTINE phase_matrix_intrpl_NQDR

SUBROUTINE MODIF_DE_TRONC

subroutine gauss

subroutine developpe_ocean_land

subroutine betal

subroutine legendre

subroutine root

subroutine profiles_WD

subroutine get_WD

1.2.6 mod_rt.f90

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
C语言是一种广泛使用的编程语言,它具有高效、灵活、可移植性强等特点,被广泛应用于操作系统、嵌入式系统、数据库、编译器等领域的开发。C语言的基本语法包括变量、数据类型、运算符、控制结构(如if语句、循环语句等)、函数、指针等。下面详细介绍C语言的基本概念和语法。 1. 变量和数据类型 在C语言中,变量用于存储数据,数据类型用于定义变量的类型和范围。C语言支持多种数据类型,包括基本数据类型(如int、float、char等)和复合数据类型(如结构体、联合等)。 2. 运算符 C语言中常用的运算符包括算术运算符(如+、、、/等)、关系运算符(如==、!=、、=、<、<=等)、逻辑运算符(如&&、||、!等)。此外,还有位运算符(如&、|、^等)和指针运算符(如、等)。 3. 控制结构 C语言中常用的控制结构包括if语句、循环语句(如for、while等)和switch语句。通过这些控制结构,可以实现程序的分支、循环和多路选择等功能。 4. 函数 函数是C语言中用于封装代码的单元,可以实现代码的复用和模块化。C语言中定义函数使用关键字“void”或返回值类型(如int、float等),并通过“{”和“}”括起来的代码块来实现函数的功能。 5. 指针 指针是C语言中用于存储变量地址的变量。通过指针,可以实现对内存的间接访问和修改。C语言中定义指针使用星号()符号,指向数组、字符串和结构体等数据结构时,还需要注意数组名和字符串常量的特殊性质。 6. 数组和字符串 数组是C语言中用于存储同类型数据的结构,可以通过索引访问和修改数组中的元素。字符串是C语言中用于存储文本数据的特殊类型,通常以字符串常量的形式出现,用双引号("...")括起来,末尾自动添加'\0'字符。 7. 结构体和联合 结构体和联合是C语言中用于存储不同类型数据的复合数据类型。结构体由多个成员组成,每个成员可以是不同的数据类型;联合由多个变量组成,它们共用同一块内存空间。通过结构体和联合,可以实现数据的封装和抽象。 8. 文件操作 C语言中通过文件操作函数(如fopen、fclose、fread、fwrite等)实现对文件的读写操作。文件操作函数通常返回文件指针,用于表示打开的文件。通过文件指针,可以进行文件的定位、读写等操作。 总之,C语言是一种功能强大、灵活高效的编程语言,广泛应用于各种领域。掌握C语言的基本语法和数据结构,可以为编程学习和实践打下坚实的基础。
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
以下是一个简单的Grasp算法的代码示例,用于处理一个二维物体的抓取问题: ```python import numpy as np # 定义物体的形状和质心 object_shape = np.array([[0, 0], [0, 1], [1, 1], [1, 0]]) object_centroid = np.array([0.5, 0.5]) # 定义机械手的夹爪宽度 gripper_width = 0.2 # 定义抓取点的数量和分辨率 num_grasp_points = 10 grasp_resolution = 0.01 # 初始化抓取点集合 grasp_points = np.zeros((num_grasp_points, 2)) # 随机生成抓取点 for i in range(num_grasp_points): # 随机生成抓取点的位置 grasp_point = np.random.uniform(-1, 1, 2) # 将抓取点移动到物体质心 grasp_point = grasp_point - np.mean(object_shape, axis=0) # 将抓取点旋转到水平方向 angle = np.arctan2(grasp_point[1], grasp_point[0]) rotation_matrix = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]]) grasp_point = np.dot(grasp_point, rotation_matrix) # 将抓取点移动到合适的位置 grasp_point[0] = np.clip(grasp_point[0], gripper_width / 2, object_shape[:, 0].max() - gripper_width / 2) grasp_point[1] = np.clip(grasp_point[1], -grasp_resolution / 2, grasp_resolution / 2) grasp_point = grasp_point + object_centroid grasp_points[i] = grasp_point # 计算抓取点的质心 grasp_points_centroid = np.mean(grasp_points, axis=0) # 将抓取点按照到物体质心的距离排序 grasp_points_distance = np.linalg.norm(grasp_points - grasp_points_centroid, axis=1) sorted_indices = np.argsort(grasp_points_distance) sorted_grasp_points = grasp_points[sorted_indices] # 输出最优的抓取点 print("最优的抓取点为:", sorted_grasp_points[0]) ``` 上述代码中,我们首先定义了物体的形状和质心,以及机械手的夹爪宽度和抓取点的数量和分辨率。然后,我们通过随机生成抓取点的位置,并对其进行一系列的变换和筛选,最终得到了一个抓取点的集合。最后,我们根据抓取点到物体质心的距离,将抓取点进行排序,并输出最优的抓取点。 需要注意的是,上述代码只是一个简单的示例,实际应用中需要根据具体的问题进行修改和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值