|
42 | 42 | def print_progress(n_complete, n_total):
|
43 | 43 | print(str(n_complete) + ' of ' + str(n_total) + ' complete: (' + str(100.0*n_complete/float(n_total)) + '%)')
|
44 | 44 |
|
45 |
| -def replace_fill_with_nan(nc_ds, var_name, var, group): |
46 |
| - raw_data = nc_ds.variables[var_name][:] |
47 |
| - raw_data[raw_data == nc_fid.variables[var_name]._FillValue] = np.nan |
48 |
| - var.append(raw_data) |
| 45 | +def replace_fill_with_nan(nc_ds, var_name, var, group, time_diag, pres_l, dataset): |
| 46 | + try: |
| 47 | + raw_data = nc_ds.variables[var_name][:] |
| 48 | + raw_data[raw_data == nc_fid.variables[var_name]._FillValue] = np.nan |
| 49 | + var.append(nc_fid.variables[var_name][:]) |
| 50 | + except KeyError: |
| 51 | + print('{0} is not in the output file {1}'.format(var_name, dataset)) |
| 52 | + print('Missing variables are replaced with {0}'.format(0)) |
| 53 | + var.append(np.zeros((len(time_diag[-1]),pres_l[-1].shape[1],pres_l[-1].shape[2]))) |
49 | 54 | group.append(var_name)
|
50 |
| - return [var, group] |
| 55 | + return[var,group] |
51 | 56 |
|
52 | 57 | #set up command line argument parser to read in name of config file to use
|
53 | 58 | parser = argparse.ArgumentParser()
|
@@ -584,97 +589,97 @@ def replace_fill_with_nan(nc_ds, var_name, var, group):
|
584 | 589 | hpbl.append(nc_fid.variables['hpbl'][:])
|
585 | 590 | inst_time_group.append('hpbl')
|
586 | 591 |
|
587 |
| - [dT_dt_lwrad, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_lwrad', dT_dt_lwrad, diag_time_group) |
| 592 | + [dT_dt_lwrad, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_lwrad', dT_dt_lwrad, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
588 | 593 |
|
589 |
| - [dT_dt_swrad, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_swrad', dT_dt_swrad, diag_time_group) |
| 594 | + [dT_dt_swrad, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_swrad', dT_dt_swrad, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
590 | 595 |
|
591 |
| - [dT_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_pbl', dT_dt_pbl, diag_time_group) |
| 596 | + [dT_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_pbl', dT_dt_pbl, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
592 | 597 |
|
593 |
| - [dT_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_deepconv', dT_dt_deepconv, diag_time_group) |
| 598 | + [dT_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_deepconv', dT_dt_deepconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
594 | 599 |
|
595 |
| - [dT_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_shalconv', dT_dt_shalconv, diag_time_group) |
| 600 | + [dT_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_shalconv', dT_dt_shalconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
596 | 601 |
|
597 |
| - [dT_dt_micro, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_micro', dT_dt_micro, diag_time_group) |
| 602 | + [dT_dt_micro, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_micro', dT_dt_micro, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
598 | 603 |
|
599 | 604 | dT_dt_conv.append(dT_dt_deepconv[-1] + dT_dt_shalconv[-1])
|
600 | 605 | diag_time_group.append('dT_dt_conv')
|
601 | 606 |
|
602 |
| - [dT_dt_ogwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_ogwd', dT_dt_ogwd, diag_time_group) |
| 607 | + [dT_dt_ogwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_ogwd', dT_dt_ogwd, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
603 | 608 |
|
604 |
| - [dT_dt_rayleigh, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_rayleigh', dT_dt_rayleigh, diag_time_group) |
| 609 | + [dT_dt_rayleigh, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_rayleigh', dT_dt_rayleigh, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
605 | 610 |
|
606 |
| - [dT_dt_cgwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_cgwd', dT_dt_cgwd, diag_time_group) |
| 611 | + [dT_dt_cgwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_cgwd', dT_dt_cgwd, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
607 | 612 |
|
608 |
| - [dT_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_phys', dT_dt_phys, diag_time_group) |
| 613 | + [dT_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_phys', dT_dt_phys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
609 | 614 |
|
610 |
| - [dT_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_nonphys', dT_dt_nonphys, diag_time_group) |
| 615 | + [dT_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dT_dt_nonphys', dT_dt_nonphys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
611 | 616 |
|
612 |
| - [dq_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_pbl', dq_dt_pbl, diag_time_group) |
| 617 | + [dq_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_pbl', dq_dt_pbl, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
613 | 618 |
|
614 |
| - [dq_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_deepconv', dq_dt_deepconv, diag_time_group) |
| 619 | + [dq_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_deepconv', dq_dt_deepconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
615 | 620 |
|
616 |
| - [dq_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_shalconv', dq_dt_shalconv, diag_time_group) |
| 621 | + [dq_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_shalconv', dq_dt_shalconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
617 | 622 |
|
618 |
| - [dq_dt_micro, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_micro', dq_dt_micro, diag_time_group) |
| 623 | + [dq_dt_micro, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_micro', dq_dt_micro, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
619 | 624 |
|
620 | 625 | dq_dt_conv.append(dq_dt_deepconv[-1] + dq_dt_shalconv[-1])
|
621 | 626 | diag_time_group.append('dq_dt_conv')
|
622 | 627 |
|
623 |
| - [dq_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_phys', dq_dt_phys, diag_time_group) |
| 628 | + [dq_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_phys', dq_dt_phys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
624 | 629 |
|
625 |
| - [dq_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_nonphys', dq_dt_nonphys, diag_time_group) |
| 630 | + [dq_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dq_dt_nonphys', dq_dt_nonphys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
626 | 631 |
|
627 |
| - [doz_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_pbl', doz_dt_pbl, diag_time_group) |
| 632 | + [doz_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_pbl', doz_dt_pbl, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
628 | 633 |
|
629 |
| - [doz_dt_prodloss, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_prodloss', doz_dt_prodloss, diag_time_group) |
| 634 | + [doz_dt_prodloss, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_prodloss', doz_dt_prodloss, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
630 | 635 |
|
631 |
| - [doz_dt_oz, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_oz', doz_dt_oz, diag_time_group) |
| 636 | + [doz_dt_oz, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_oz', doz_dt_oz, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
632 | 637 |
|
633 |
| - [doz_dt_T, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_T', doz_dt_T, diag_time_group) |
| 638 | + [doz_dt_T, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_T', doz_dt_T, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
634 | 639 |
|
635 |
| - [doz_dt_ovhd, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_ovhd', doz_dt_ovhd, diag_time_group) |
| 640 | + [doz_dt_ovhd, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_ovhd', doz_dt_ovhd, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
636 | 641 |
|
637 |
| - [doz_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_phys', doz_dt_phys, diag_time_group) |
| 642 | + [doz_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_phys', doz_dt_phys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
638 | 643 |
|
639 |
| - [doz_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_nonphys', doz_dt_nonphys, diag_time_group) |
| 644 | + [doz_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'doz_dt_nonphys', doz_dt_nonphys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
640 | 645 |
|
641 |
| - [du_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_pbl', du_dt_pbl, diag_time_group) |
| 646 | + [du_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_pbl', du_dt_pbl, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
642 | 647 |
|
643 |
| - [du_dt_ogwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_ogwd', du_dt_ogwd, diag_time_group) |
| 648 | + [du_dt_ogwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_ogwd', du_dt_ogwd, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
644 | 649 |
|
645 |
| - [du_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_deepconv', du_dt_deepconv, diag_time_group) |
| 650 | + [du_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_deepconv', du_dt_deepconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
646 | 651 |
|
647 |
| - [du_dt_cgwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_cgwd', du_dt_cgwd, diag_time_group) |
| 652 | + [du_dt_cgwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_cgwd', du_dt_cgwd, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
648 | 653 |
|
649 |
| - [du_dt_rayleigh, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_rayleigh', du_dt_rayleigh, diag_time_group) |
| 654 | + [du_dt_rayleigh, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_rayleigh', du_dt_rayleigh, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
650 | 655 |
|
651 |
| - [du_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_shalconv', du_dt_shalconv, diag_time_group) |
| 656 | + [du_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_shalconv', du_dt_shalconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
652 | 657 |
|
653 | 658 | du_dt_conv.append(du_dt_deepconv[-1] + du_dt_shalconv[-1])
|
654 | 659 | diag_time_group.append('du_dt_conv')
|
655 | 660 |
|
656 |
| - [du_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_phys', du_dt_phys, diag_time_group) |
| 661 | + [du_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_phys', du_dt_phys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
657 | 662 |
|
658 |
| - [du_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_nonphys', du_dt_nonphys, diag_time_group) |
| 663 | + [du_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'du_dt_nonphys', du_dt_nonphys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
659 | 664 |
|
660 |
| - [dv_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_pbl', dv_dt_pbl, diag_time_group) |
| 665 | + [dv_dt_pbl, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_pbl', dv_dt_pbl, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
661 | 666 |
|
662 |
| - [dv_dt_ogwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_ogwd', dv_dt_ogwd, diag_time_group) |
| 667 | + [dv_dt_ogwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_ogwd', dv_dt_ogwd, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
663 | 668 |
|
664 |
| - [dv_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_deepconv', dv_dt_deepconv, diag_time_group) |
| 669 | + [dv_dt_deepconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_deepconv', dv_dt_deepconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
665 | 670 |
|
666 |
| - [dv_dt_cgwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_cgwd', dv_dt_cgwd, diag_time_group) |
| 671 | + [dv_dt_cgwd, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_cgwd', dv_dt_cgwd, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
667 | 672 |
|
668 |
| - [dv_dt_rayleigh, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_rayleigh', dv_dt_rayleigh, diag_time_group) |
| 673 | + [dv_dt_rayleigh, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_rayleigh', dv_dt_rayleigh, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
669 | 674 |
|
670 |
| - [dv_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_shalconv', dv_dt_shalconv, diag_time_group) |
| 675 | + [dv_dt_shalconv, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_shalconv', dv_dt_shalconv, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
671 | 676 |
|
672 | 677 | dv_dt_conv.append(dv_dt_deepconv[-1] + dv_dt_shalconv[-1])
|
673 | 678 | diag_time_group.append('dv_dt_conv')
|
674 | 679 |
|
675 |
| - [dv_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_phys', dv_dt_phys, diag_time_group) |
| 680 | + [dv_dt_phys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_phys', dv_dt_phys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
676 | 681 |
|
677 |
| - [dv_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_nonphys', dv_dt_nonphys, diag_time_group) |
| 682 | + [dv_dt_nonphys, diag_time_group] = replace_fill_with_nan(nc_fid, 'dv_dt_nonphys', dv_dt_nonphys, diag_time_group, time_diag, pres_l, scm_datasets[i]) |
678 | 683 |
|
679 | 684 | tprcp_accum.append(nc_fid.variables['tprcp_accum'][:])
|
680 | 685 | diag_time_group.append('tprcp_accum')
|
|
0 commit comments