rs1729 / RS

radiosonde decoding
GNU General Public License v3.0
170 stars 56 forks source link

RS41 - dew point #26

Closed pavolgaj closed 3 years ago

pavolgaj commented 3 years ago

It would be useful to have also a dew point value in the output if "--ptu" option is used. I don't know if this value is directly in data from radiosonde or it could be only calculated from temperature and humidity.

rs1729 commented 3 years ago

Sorry, but I didn't want to include too many derived values, same with AUX-O3-data or pressure altitude. Maybe I will change my mind one day, but for now, maybe you include it yourself if you want that output. You can look how it is calculated here: https://en.wikipedia.org/wiki/Dew_point or look at https://github.com/einergehtnochrein/ra-firmware/blob/master/src/rs41/rs41metrology.c#L262 You could change prn_ptu() https://github.com/rs1729/RS/blob/master/demod/mod/rs41mod.c#L1446 and add dew point calculation like this:

static int prn_ptu(gpx_t *gpx) {
    fprintf(stdout, " ");
    if (gpx->T > -273.0) fprintf(stdout, " T=%.1fC ", gpx->T);
    if (gpx->RH > -0.5)  fprintf(stdout, " RH=%.0f%% ", gpx->RH);
    if (gpx->P > 0.0) {
        if (gpx->P < 100.0) fprintf(stdout, " P=%.2fhPa ", gpx->P);
        else                fprintf(stdout, " P=%.1fhPa ", gpx->P);
    }
    if (gpx->option.ptu == 2) {
        if (gpx->RH2 > -0.5)  fprintf(stdout, " RH2=%.0f%% ", gpx->RH2);
    }

    // dew point
    float rh = gpx->RH;
    float Td = -273.15f; // dew point Td
    if (gpx->option.ptu == 2) rh = gpx->RH2;
    if (rh > 0.0f && gpx->T > -273.0f) {
        float gamma = logf(rh / 100.0f) + (17.625f * gpx->T / (243.04f + gpx->T));
        Td = 243.04f * gamma / (17.625f - gamma);
        fprintf(stdout, " Td=%.1fC ", Td);
    }
    return 0;
}

Hm... maybe I include it as an additional option...

rs1729 commented 3 years ago

rs41mod: added dew point option "--dewp" (don't forget "--ptu" or "--ptu2" resp.)