Changeset 2085 in lmdz_wrf
- Timestamp:
- Aug 12, 2018, 2:59:18 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r2035 r2085 43 43 44 44 # Variable name might come with a statistical surname... 45 statsurname=['MIN','MAX','MEAN','STD', 'SUM', 'TURB', 'VAR', \ 46 'min','max','mean','std', 'sum', 'turb', 'var'] 45 statsurname=['MIN', 'MAX', 'MEAN', 'STD', 'SUM', 'TURB', 'VAR', \ 46 'min', 'max', 'mean', 'std', 'sum', 'turb', 'var'] 47 48 Lstatsurname = {'MIN': 'minimum', 'MAX': 'maximum', 'MEAN': 'mean', \ 49 'STD': 'standard deviation', 'SUM': 'summ', 'TURB': 'turbulence', \ 50 'VAR': 'variability', 'min': 'minimum', 'max': 'maximum', 'mean': 'mean', \ 51 'std': 'standard deviation', 'sum': 'summ', 'turb': 'turbulence', \ 52 'var': 'variability'} 47 53 48 54 # masked array (for type tests) … … 1579 1585 varName = varName.replace(st,'') 1580 1586 ifst = True 1587 break 1581 1588 varn = varName 1582 1589 … … 1599 1606 'rainbow', '$'+varn[6:Lvarn+1]+'$', varn[6:Lvarn+1]] 1600 1607 else: 1601 varvals = [values[1].replace(' ',''), values[2].replace(' ',''), \ 1602 np.float(values[3]), np.float(values[4]),values[5].replace(' ',''),\ 1603 values[6].replace(' ',''), values[7].replace(' ',''), \ 1604 values[8].replace(' ',''), values[9].replace(' ','')] 1608 if ifst: 1609 Lstat = Lstatsurname[st] 1610 stn = st.lower() 1611 latexv = values[8].replace(' ','') 1612 latexn = latexv[0:len(latexv)-1] + stn + '$' 1613 varvals = [values[1].replace(' ','') + stn, \ 1614 values[2].replace(' ',''), np.float(values[3]), \ 1615 np.float(values[4]), Lstat + '|' + values[5].replace(' ',''), \ 1616 values[6].replace(' ',''), values[7].replace(' ',''), \ 1617 latexn, values[9].replace(' ','') + stn] 1618 else: 1619 varvals = [values[1].replace(' ',''), values[2].replace(' ',''), \ 1620 np.float(values[3]), np.float(values[4]), \ 1621 values[5].replace(' ',''), values[6].replace(' ',''), \ 1622 values[7].replace(' ',''), values[8].replace(' ',''), \ 1623 values[9].replace(' ','')] 1605 1624 if values[0] == varn: 1606 1625 ncf.close() -
trunk/tools/get_WRFsounding-surface_data.bash
r2067 r2085 279 279 echo " " >> ${ofileins} 280 280 # CF varname 281 CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | tr ':' ' ' |\282 awk '{print $1}'`281 CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | \ 282 grep -v variables_values | tr ':' ' ' | awk '{print $1}'` 283 283 if test $? -ne 0; then 284 284 echo ${errmsg} … … 433 433 echo " " >> ${ofileins} 434 434 fi 435 #Adding non-diagnostic variables 436 if test ! ${nondiagvs} = 'None'; then 437 varsadd=`echo ${nondiagvs} | tr ':' ' '` 438 for vadd in ${varsadd}; do 439 python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd} \ 440 -f ${simsfcmapdiagsf} 441 if test $? -ne 0; then 442 echo ${errmsg} 443 echo " python failed!!" 444 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ 445 -f ${simsfcmapdiagsf} 446 exit 447 rm ${simsfcmapdiagsf} 448 fi 449 echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins} 450 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ 451 -f ${simsfcmapdiagsf} >> ${ofileins} 452 echo " " >> ${ofileins} 453 # CF varname, no need? 454 CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | \ 455 grep -v variables_values | tr ':' ' ' | awk '{print $1}'` 456 if test $? -ne 0; then 457 echo ${errmsg} 458 echo " python failed!!" 459 echo python $pyHOME/generic.py -o variables_values -S ${vadd} 460 exit 461 rm ${simsfcmapdiagsf} 462 fi 463 python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf} \ 464 -v ${vadd} 465 if test $? -ne 0; then 466 echo ${errmsg} 467 echo " python failed!!" 468 echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ 469 -f ${simsfcmapdiagsf} -v ${vadd} 470 exit 471 rm ${simsfcmapdiagsf} 472 fi 473 done 474 fi 475 fi 476 } 477 478 function get_WRFCDXsurface_data(){ 479 # Function to get the WRFCDX data to compute analysis in a surface point 480 # stlon= longitude value of the station 481 # stlat= latitude value of the station 482 # filen= name of the file 483 # lonvarn= name of the longitude variable 484 # latvarn= name of the latitude variable 485 # sfcdiagnames= diagnostics to compute (as ':' separated list) 486 # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for 487 # without) 488 489 funcvals=$1 490 491 stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` 492 stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` 493 filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` 494 lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'` 495 latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'` 496 sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'` 497 nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $7}'` 498 499 vals=${lonvarn}':'${latvarn}':Time|0' 500 gridsndv=`python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ 501 -v ${stlon},${stlat} | tr ' ' '!'` 502 echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} 503 echo python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ 504 -v ${stlon},${stlat} >> ${ofileins} 505 echo " " >> ${ofileins} 506 xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ 507 awk '{print $1}'` 508 ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ 509 awk '{print $2}'` 510 dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'` 511 512 xsnd1=`expr ${xsnd} + 1` 513 ysnd1=`expr ${ysnd} + 1` 514 515 # Getting values 516 if ${fscratch}; then rm ${simsfcptf} >& /dev/null; fi 517 if test ! -f ${simsfcptf}; then 518 values='Time,0,-1,1@south_north,'${ysnd}','${ysnd}',1@' 519 values=${values}'west_east,'${xsnd}','${xsnd}',1:False' 520 python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 521 -S ${values} -v all 522 if test $? -ne 0; then 523 echo ${errmsg} 524 echo " python failed!!" 525 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 526 -S "'"${values}"'" -v all 527 exit 528 fi 529 echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins} 530 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 531 -S "'"${values}"'" -v all >> ${ofileins} 532 echo " " >> ${ofileins} 533 534 ofilen='newfile_multidims.nc' 535 mv ${ofilen} ${simsfcptf} 536 fi 537 538 # Computing sfc diagnostics 539 if test ! ${sfcdiagnames} = 'None'; then 540 sfcdiagd='Time@WRFtime' 541 diagns=`echo ${sfcdiagnames} | tr ':' ' '` 542 543 idiag=1 544 for diagn in ${diagns}; do 545 diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |\ 546 awk '{print $2"|"$3}'` 547 if test ${idiag} -eq 1; then 548 sfcdiagvals=${diagv} 549 else 550 sfcdiagvals=${sfcdiagvals}','${diagv} 551 fi 552 idiag=`expr ${idiag} + 1` 553 done 554 555 if ${fscratch}; then rm ${simsfcdiagsf}; fi 556 if test ! -f ${simsfcdiagsf}; then 557 python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals} 558 if test $? -ne 0; then 559 echo ${errmsg} 560 echo " python failed!!" 561 echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ 562 -v "'"${sfcdiagvals}"'" 563 exit 564 fi 565 echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins} 566 echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ 567 -v "'"${sfcdiagvals}"'" >> ${ofileins} 568 echo " " >> ${ofileins} 569 mv diagnostics.nc ${simsfcdiagsf} 570 fi 571 fi 572 573 #Adding non-diagnostic variables 574 if test ! ${nondiagvs} = 'None'; then 575 # If there was not diagnostics 576 if test ! -f ${simsfcdiagsf}; then 577 dddv='Time@Times' 578 selvars='Times' 579 python ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcptf} -v ${selvars} 580 if test $? -ne 0; then 581 echo ${errmsg} 582 echo " python failed!!" 583 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf} \ 584 -v ${vars} 585 exit 586 rm ${simsfcptf} 587 fi 588 echo "* creation of diagnostics file at sfc point: "${stlon}", "${stlat} >> \ 589 ${ofileins} 590 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf} \ 591 -v ${selvars} >> ${ofileins} 592 echo " " >> ${ofileins} 593 mv selvar_new.nc ${simsfcdiagsf} 594 python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ 595 -f ${simsfcdiagsf} -v time 596 if test $? -ne 0; then 597 echo ${errmsg} 598 echo " python failed!!" 599 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ 600 -f ${simsfcdiagsf} -v time 601 exit 602 rm ${simsfcdiagsf} 603 fi 604 echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ 605 ${stlat} >> ${ofileins} 606 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ 607 -f ${simsfcdiagsf} -v time >> ${ofileins} 608 echo " " >> ${ofileins} 609 fi 610 varsadd=`echo ${nondiagvs} | tr ':' ' '` 611 for vadd in ${varsadd}; do 612 python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} -f ${simsfcdiagsf} 613 if test $? -ne 0; then 614 echo ${errmsg} 615 echo " python failed!!" 616 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ 617 -f ${simsfcdiagsf} 618 exit 619 rm ${simsfcdiagsf} 620 fi 621 echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> ${ofileins} 622 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ 623 -f ${simsfcdiagsf} >> ${ofileins} 624 echo " " >> ${ofileins} 625 # CF varname 626 CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | \ 627 grep -v variables_values | tr ':' ' ' | awk '{print $1}'` 628 if test $? -ne 0; then 629 echo ${errmsg} 630 echo " python failed!!" 631 echo python $pyHOME/generic.py -o variables_values -S ${vadd} 632 exit 633 rm ${simsfcdiagsf} 634 fi 635 python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} -v ${vadd} 636 if test $? -ne 0; then 637 echo ${errmsg} 638 echo " python failed!!" 639 echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} \ 640 -v ${vadd} 641 exit 642 rm ${simsfcdiagsf} 643 fi 644 done 645 fi 646 } 647 648 function get_WRFCDXsfc2D_data(){ 649 # Function to get the data from WRFCDX to compute analysis in a surface map 650 # filen= name of the file 651 # sfcdiagnames= diagnostics to compute (as ':' separated list) 652 # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for 653 # without) 654 # sfcmapdiagd= name of the dimensions and dimension variables to use for diagnostics 655 656 funcvals=$1 657 658 filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` 659 sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` 660 nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` 661 sfcmapdiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'` 662 663 # Computing sfc diagnostics 664 if test ! ${sfcdiagnames} = 'None'; then 665 diagns=`echo ${sfcdiagnames} | tr ':' ' '` 666 667 # getting that variables only required for the diagnostics 668 vardiags='' 669 idiag=1 670 for diagn in ${diagns}; do 671 diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' | \ 672 awk '{print $2"|"$3}'` 673 if test ${idiag} -eq 1; then 674 sfcdiagvals=${diagv} 675 vardiags=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ':'` 676 else 677 sfcdiagvals=${sfcdiagvals}','${diagv} 678 vardiag=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ' '` 679 for vd in ${vardiag}; do 680 if ! $(isin_list ${vardiags} ${vd}); then vardiags=${vardiags}':'${vd}; fi 681 done 682 fi 683 idiag=`expr ${idiag} + 1` 684 done 685 686 # Inlcuding non-diagnostics 687 if test ! ${nondiagvs} = 'None'; then 688 nvns=`echo ${nondiagvs} | tr ':' ' '` 689 for vn in ${nvns}; do 690 if ! $(isin_list ${vardiags} ${vn}); then vardiags=${vardiags}':'${vn}; fi 691 done 692 if ! $(isin_list ${vardiags} 'time'); then vardiags=${vardiags}':time'; fi 693 fi 694 else 695 vardiags='LON:LAT:Times:'${nondiagvs} 696 fi 697 vardiag=`echo ${vardiags} | tr ':' ','` 698 699 # Getting values 700 if ${fscratch}; then rm ${simsfcmapf} >& /dev/null; fi 701 if test ! -f ${simsfcmapf}; then 702 values='Time,0,-1,1@south_north,0,-1,1@west_east,0,-1,1:False' 703 python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 704 -S ${values} -v ${vardiag} 705 if test $? -ne 0; then 706 echo ${errmsg} 707 echo " python failed!!" 708 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 709 -S "'"${values}"'" -v ${vardiag} 710 exit 711 fi 712 echo "* get values for 2D map diagnostics: " >> ${ofileins} 713 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 714 -S "'"${values}"'" -v ${vardiag} >> ${ofileins} 715 echo " " >> ${ofileins} 716 717 ofilen='newfile_multidims.nc' 718 mv ${ofilen} ${simsfcmapf} 719 fi 720 721 if ${fscratch}; then rm ${simsfcmapdiagsf}; fi 722 if test ! -f ${simsfcmapdiagsf}; then 723 if test ! ${sfcdiagnames} = 'None'; then 724 python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd} \ 725 -v ${sfcdiagvals} 726 if test $? -ne 0; then 727 echo ${errmsg} 728 echo " python failed!!" 729 echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'"\ 730 -v "'"${sfcdiagvals}"'" 731 exit 732 fi 733 echo "* diagnostics for sfc 2D map: " >> ${ofileins} 734 echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \ 735 -v "'"${sfcdiagvals}"'" >> ${ofileins} 736 echo " " >> ${ofileins} 737 mv diagnostics.nc ${simsfcmapdiagsf} 738 fi 739 # If there was not diagnostics 740 if test ! -f ${simsfcmapdiagsf}; then 741 dddv='Time@Times' 742 selvars='LON,LAT,Times' 743 python ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcmapf} -v ${selvars} 744 if test $? -ne 0; then 745 echo ${errmsg} 746 echo " python failed!!" 747 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${ddv}"'" -f ${simsfmapf} \ 748 -v ${vars} 749 exit 750 rm ${simsfcmapf} 751 fi 752 echo "* creation of diagnostics file for 2D map:" >> ${ofileins} 753 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcmapf} \ 754 -v ${selvars} >> ${ofileins} 755 echo " " >> ${ofileins} 756 mv selvar_new.nc ${simsfcmapdiagsf} 757 python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ 758 -f ${simsfcmapdiagsf} -v time 759 if test $? -ne 0; then 760 echo ${errmsg} 761 echo " python failed!!" 762 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ 763 -f ${simsfcmapdiagsf} -v time 764 exit 765 rm ${simsfcmapdiagsf} 766 fi 767 echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ 768 ${stlat} >> ${ofileins} 769 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ 770 -f ${simsfcmapdiagsf} -v time >> ${ofileins} 771 echo " " >> ${ofileins} 772 fi 773 435 774 #Adding non-diagnostic variables 436 775 if test ! ${nondiagvs} = 'None'; then … … 453 792 # CF varname 454 793 CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | \ 455 tr ':' ' ' | awk '{print $1}'`794 grep -v variables_values | tr ':' ' ' | awk '{print $1}'` 456 795 if test $? -ne 0; then 457 796 echo ${errmsg} … … 476 815 } 477 816 478 function get_WRFCDXsurface_data(){479 # Function to get the WRFCDX data to compute analysis in a surface point480 # stlon= longitude value of the station481 # stlat= latitude value of the station482 # filen= name of the file483 # lonvarn= name of the longitude variable484 # latvarn= name of the latitude variable485 # sfcdiagnames= diagnostics to compute (as ':' separated list)486 # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for487 # without)488 489 funcvals=$1490 491 stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'`492 stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'`493 filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'`494 lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'`495 latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'`496 sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'`497 nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $7}'`498 499 vals=${lonvarn}':'${latvarn}':Time|0'500 gridsndv=`python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \501 -v ${stlon},${stlat} | tr ' ' '!'`502 echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins}503 echo python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \504 -v ${stlon},${stlat} >> ${ofileins}505 echo " " >> ${ofileins}506 xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \507 awk '{print $1}'`508 ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \509 awk '{print $2}'`510 dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'`511 512 xsnd1=`expr ${xsnd} + 1`513 ysnd1=`expr ${ysnd} + 1`514 515 # Getting values516 if ${fscratch}; then rm ${simsfcptf} >& /dev/null; fi517 if test ! -f ${simsfcptf}; then518 values='Time,0,-1,1@south_north,'${ysnd}','${ysnd}',1@'519 values=${values}'west_east,'${xsnd}','${xsnd}',1:False'520 python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \521 -S ${values} -v all522 if test $? -ne 0; then523 echo ${errmsg}524 echo " python failed!!"525 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \526 -S "'"${values}"'" -v all527 exit528 fi529 echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins}530 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \531 -S "'"${values}"'" -v all >> ${ofileins}532 echo " " >> ${ofileins}533 534 ofilen='newfile_multidims.nc'535 mv ${ofilen} ${simsfcptf}536 fi537 538 # Computing sfc diagnostics539 if test ! ${sfcdiagnames} = 'None'; then540 sfcdiagd='Time@WRFtime'541 diagns=`echo ${sfcdiagnames} | tr ':' ' '`542 543 idiag=1544 for diagn in ${diagns}; do545 diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |\546 awk '{print $2"|"$3}'`547 if test ${idiag} -eq 1; then548 sfcdiagvals=${diagv}549 else550 sfcdiagvals=${sfcdiagvals}','${diagv}551 fi552 idiag=`expr ${idiag} + 1`553 done554 555 if ${fscratch}; then rm ${simsfcdiagsf}; fi556 if test ! -f ${simsfcdiagsf}; then557 python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals}558 if test $? -ne 0; then559 echo ${errmsg}560 echo " python failed!!"561 echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \562 -v "'"${sfcdiagvals}"'"563 exit564 fi565 echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins}566 echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \567 -v "'"${sfcdiagvals}"'" >> ${ofileins}568 echo " " >> ${ofileins}569 mv diagnostics.nc ${simsfcdiagsf}570 fi571 fi572 573 #Adding non-diagnostic variables574 if test ! ${nondiagvs} = 'None'; then575 # If there was not diagnostics576 if test ! -f ${simsfcdiagsf}; then577 dddv='Time@Times'578 selvars='Times'579 python ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcptf} -v ${selvars}580 if test $? -ne 0; then581 echo ${errmsg}582 echo " python failed!!"583 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf} \584 -v ${vars}585 exit586 rm ${simsfcptf}587 fi588 echo "* creation of diagnostics file at sfc point: "${stlon}", "${stlat} >> \589 ${ofileins}590 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf} \591 -v ${selvars} >> ${ofileins}592 echo " " >> ${ofileins}593 mv selvar_new.nc ${simsfcdiagsf}594 python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \595 -f ${simsfcdiagsf} -v time596 if test $? -ne 0; then597 echo ${errmsg}598 echo " python failed!!"599 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \600 -f ${simsfcdiagsf} -v time601 exit602 rm ${simsfcdiagsf}603 fi604 echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \605 ${stlat} >> ${ofileins}606 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \607 -f ${simsfcdiagsf} -v time >> ${ofileins}608 echo " " >> ${ofileins}609 fi610 varsadd=`echo ${nondiagvs} | tr ':' ' '`611 for vadd in ${varsadd}; do612 python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} -f ${simsfcdiagsf}613 if test $? -ne 0; then614 echo ${errmsg}615 echo " python failed!!"616 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \617 -f ${simsfcdiagsf}618 exit619 rm ${simsfcdiagsf}620 fi621 echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> ${ofileins}622 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \623 -f ${simsfcdiagsf} >> ${ofileins}624 echo " " >> ${ofileins}625 # CF varname626 CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | tr ':' ' ' |\627 awk '{print $1}'`628 if test $? -ne 0; then629 echo ${errmsg}630 echo " python failed!!"631 echo python $pyHOME/generic.py -o variables_values -S ${vadd}632 exit633 rm ${simsfcdiagsf}634 fi635 python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} -v ${vadd}636 if test $? -ne 0; then637 echo ${errmsg}638 echo " python failed!!"639 echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} \640 -v ${vadd}641 exit642 rm ${simsfcdiagsf}643 fi644 done645 fi646 }647 648 function get_WRFCDXsfc2D_data(){649 # Function to get the data from WRFCDX to compute analysis in a surface map650 # filen= name of the file651 # sfcdiagnames= diagnostics to compute (as ':' separated list)652 # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for653 # without)654 # sfcmapdiagd= name of the dimensions and dimension variables to use for diagnostics655 656 funcvals=$1657 658 filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'`659 sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'`660 nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'`661 sfcmapdiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'`662 663 # Computing sfc diagnostics664 if test ! ${sfcdiagnames} = 'None'; then665 diagns=`echo ${sfcdiagnames} | tr ':' ' '`666 667 # getting that variables only required for the diagnostics668 vardiags=''669 idiag=1670 for diagn in ${diagns}; do671 diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' | \672 awk '{print $2"|"$3}'`673 if test ${idiag} -eq 1; then674 sfcdiagvals=${diagv}675 vardiags=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ':'`676 else677 sfcdiagvals=${sfcdiagvals}','${diagv}678 vardiag=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ' '`679 for vd in ${vardiag}; do680 if ! $(isin_list ${vardiags} ${vd}); then vardiags=${vardiags}':'${vd}; fi681 done682 fi683 idiag=`expr ${idiag} + 1`684 done685 686 # Inlcuding non-diagnostics687 if test ! ${nondiagvs} = 'None'; then688 nvns=`echo ${nondiagvs} | tr ':' ' '`689 for vn in ${nvns}; do690 if ! $(isin_list ${vardiags} ${vn}); then vardiags=${vardiags}':'${vn}; fi691 done692 if ! $(isin_list ${vardiags} 'time'); then vardiags=${vardiags}':time'; fi693 fi694 else695 vardiags='LON:LAT:Times:'${nondiagvs}696 fi697 vardiag=`echo ${vardiags} | tr ':' ','`698 699 # Getting values700 if ${fscratch}; then rm ${simsfcmapf} >& /dev/null; fi701 if test ! -f ${simsfcmapf}; then702 values='Time,0,-1,1@south_north,0,-1,1@west_east,0,-1,1:False'703 python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \704 -S ${values} -v ${vardiag}705 if test $? -ne 0; then706 echo ${errmsg}707 echo " python failed!!"708 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \709 -S "'"${values}"'" -v ${vardiag}710 exit711 fi712 echo "* get values for 2D map diagnostics: " >> ${ofileins}713 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \714 -S "'"${values}"'" -v ${vardiag} >> ${ofileins}715 echo " " >> ${ofileins}716 717 ofilen='newfile_multidims.nc'718 mv ${ofilen} ${simsfcmapf}719 fi720 721 if ${fscratch}; then rm ${simsfcmapdiagsf}; fi722 if test ! -f ${simsfcmapdiagsf}; then723 if test ! ${sfcdiagnames} = 'None'; then724 python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd} \725 -v ${sfcdiagvals}726 if test $? -ne 0; then727 echo ${errmsg}728 echo " python failed!!"729 echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'"\730 -v "'"${sfcdiagvals}"'"731 exit732 fi733 echo "* diagnostics for sfc 2D map: " >> ${ofileins}734 echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \735 -v "'"${sfcdiagvals}"'" >> ${ofileins}736 echo " " >> ${ofileins}737 mv diagnostics.nc ${simsfcmapdiagsf}738 fi739 # If there was not diagnostics740 if test ! -f ${simsfcmapdiagsf}; then741 dddv='Time@Times'742 selvars='LON,LAT,Times'743 python ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcmapf} -v ${selvars}744 if test $? -ne 0; then745 echo ${errmsg}746 echo " python failed!!"747 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${ddv}"'" -f ${simsfmapf} \748 -v ${vars}749 exit750 rm ${simsfcmapf}751 fi752 echo "* creation of diagnostics file for 2D map:" >> ${ofileins}753 echo python ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcmapf} \754 -v ${selvars} >> ${ofileins}755 echo " " >> ${ofileins}756 mv selvar_new.nc ${simsfcmapdiagsf}757 python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \758 -f ${simsfcmapdiagsf} -v time759 if test $? -ne 0; then760 echo ${errmsg}761 echo " python failed!!"762 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \763 -f ${simsfcmapdiagsf} -v time764 exit765 rm ${simsfcmapdiagsf}766 fi767 echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \768 ${stlat} >> ${ofileins}769 echo python ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \770 -f ${simsfcmapdiagsf} -v time >> ${ofileins}771 echo " " >> ${ofileins}772 fi773 774 #Adding non-diagnostic variables775 if test ! ${nondiagvs} = 'None'; then776 varsadd=`echo ${nondiagvs} | tr ':' ' '`777 for vadd in ${varsadd}; do778 python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd} \779 -f ${simsfcmapdiagsf}780 if test $? -ne 0; then781 echo ${errmsg}782 echo " python failed!!"783 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \784 -f ${simsfcmapdiagsf}785 exit786 rm ${simsfcmapdiagsf}787 fi788 echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins}789 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \790 -f ${simsfcmapdiagsf} >> ${ofileins}791 echo " " >> ${ofileins}792 # CF varname793 CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | \794 tr ':' ' ' | awk '{print $1}'`795 if test $? -ne 0; then796 echo ${errmsg}797 echo " python failed!!"798 echo python $pyHOME/generic.py -o variables_values -S ${vadd}799 exit800 rm ${simsfcmapdiagsf}801 fi802 python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf} \803 -v ${vadd}804 if test $? -ne 0; then805 echo ${errmsg}806 echo " python failed!!"807 echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \808 -f ${simsfcmapdiagsf} -v ${vadd}809 exit810 rm ${simsfcmapdiagsf}811 fi812 done813 fi814 fi815 }816 817 817 818 818 ####### #######
Note: See TracChangeset
for help on using the changeset viewer.